git.iko.soy/typeable/pandoc
on master help sign in
DocBook reader: Issue IgnoredElement warnings.
01bbb52John MacFarlane
src/Text/Pandoc/Readers/DocBook.hs+37−28
@@ -24,8 +24,9 @@ import Data.Text (Text)
24import qualified Data.Text as T
24import qualified Data.Text as T
25import Text.HTML.TagSoup.Entity (lookupEntity)
25import Text.HTML.TagSoup.Entity (lookupEntity)
26import Text.Pandoc.Builder
26import Text.Pandoc.Builder
27−import Text.Pandoc.Class (PandocMonad)
27+import Text.Pandoc.Class (PandocMonad, report)
28import Text.Pandoc.Options
28import Text.Pandoc.Options
29+import Text.Pandoc.Logging (LogMessage(..))
29import Text.Pandoc.Shared (crFilter, safeRead)
30import Text.Pandoc.Shared (crFilter, safeRead)
30import Text.TeXMath (readMathML, writeTeX)
31import Text.TeXMath (readMathML, writeTeX)
31import Text.XML.Light
32import Text.XML.Light
@@ -690,8 +691,8 @@ parseBlock (Text (CData _ s _)) = if all isSpace s
690parseBlock (CRef x) = return $ plain $ str $ map toUpper x
691parseBlock (CRef x) = return $ plain $ str $ map toUpper x
691parseBlock (Elem e) =
692parseBlock (Elem e) =
692 case qName (elName e) of
693 case qName (elName e) of
693− "toc" -> return mempty -- skip TOC, since in pandoc it's autogenerated
694+ "toc" -> skip -- skip TOC, since in pandoc it's autogenerated
694− "index" -> return mempty -- skip index, since page numbers meaningless
695+ "index" -> skip -- skip index, since page numbers meaningless
695 "para" -> parseMixed para (elContent e)
696 "para" -> parseMixed para (elContent e)
696 "formalpara" -> do
697 "formalpara" -> do
697 tit <- case filterChild (named "title") e of
698 tit <- case filterChild (named "title") e of
@@ -703,9 +704,9 @@ parseBlock (Elem e) =
703 "ackno" -> parseMixed para (elContent e)
704 "ackno" -> parseMixed para (elContent e)
704 "epigraph" -> parseBlockquote
705 "epigraph" -> parseBlockquote
705 "blockquote" -> parseBlockquote
706 "blockquote" -> parseBlockquote
706− "attribution" -> return mempty
707+ "attribution" -> skip
707− "titleabbrev" -> return mempty
708+ "titleabbrev" -> skip
708− "authorinitials" -> return mempty
709+ "authorinitials" -> skip
709 "bibliography" -> sect 0
710 "bibliography" -> sect 0
710 "bibliodiv" -> sect 1
711 "bibliodiv" -> sect 1
711 "biblioentry" -> parseMixed para (elContent e)
712 "biblioentry" -> parseMixed para (elContent e)
@@ -745,9 +746,9 @@ parseBlock (Elem e) =
745 <$> getBlocks e
746 <$> getBlocks e
746 "warning" -> blockQuote . (para (strong $ str "Warning") <>)
747 "warning" -> blockQuote . (para (strong $ str "Warning") <>)
747 <$> getBlocks e
748 <$> getBlocks e
748− "area" -> return mempty
749+ "area" -> skip
749− "areaset" -> return mempty
750+ "areaset" -> skip
750− "areaspec" -> return mempty
751+ "areaspec" -> skip
751 "qandadiv" -> gets dbSectionLevel >>= sect . (+1)
752 "qandadiv" -> gets dbSectionLevel >>= sect . (+1)
752 "question" -> addToStart (strong (str "Q:") <> str " ") <$> getBlocks e
753 "question" -> addToStart (strong (str "Q:") <> str " ") <$> getBlocks e
753 "answer" -> addToStart (strong (str "A:") <> str " ") <$> getBlocks e
754 "answer" -> addToStart (strong (str "A:") <> str " ") <$> getBlocks e
@@ -770,22 +771,22 @@ parseBlock (Elem e) =
770 "variablelist" -> definitionList <$> deflistitems
771 "variablelist" -> definitionList <$> deflistitems
771 "figure" -> getFigure e
772 "figure" -> getFigure e
772 "mediaobject" -> para <$> getMediaobject e
773 "mediaobject" -> para <$> getMediaobject e
773− "caption" -> return mempty
774+ "caption" -> skip
774 "info" -> addMetadataFromElement e
775 "info" -> addMetadataFromElement e
775 "articleinfo" -> addMetadataFromElement e
776 "articleinfo" -> addMetadataFromElement e
776− "sectioninfo" -> return mempty -- keywords & other metadata
777+ "sectioninfo" -> skip -- keywords & other metadata
777− "refsectioninfo" -> return mempty -- keywords & other metadata
778+ "refsectioninfo" -> skip -- keywords & other metadata
778− "refsect1info" -> return mempty -- keywords & other metadata
779+ "refsect1info" -> skip -- keywords & other metadata
779− "refsect2info" -> return mempty -- keywords & other metadata
780+ "refsect2info" -> skip -- keywords & other metadata
780− "refsect3info" -> return mempty -- keywords & other metadata
781+ "refsect3info" -> skip -- keywords & other metadata
781− "sect1info" -> return mempty -- keywords & other metadata
782+ "sect1info" -> skip -- keywords & other metadata
782− "sect2info" -> return mempty -- keywords & other metadata
783+ "sect2info" -> skip -- keywords & other metadata
783− "sect3info" -> return mempty -- keywords & other metadata
784+ "sect3info" -> skip -- keywords & other metadata
784− "sect4info" -> return mempty -- keywords & other metadata
785+ "sect4info" -> skip -- keywords & other metadata
785− "sect5info" -> return mempty -- keywords & other metadata
786+ "sect5info" -> skip -- keywords & other metadata
786− "chapterinfo" -> return mempty -- keywords & other metadata
787+ "chapterinfo" -> skip -- keywords & other metadata
787− "glossaryinfo" -> return mempty -- keywords & other metadata
788+ "glossaryinfo" -> skip -- keywords & other metadata
788− "appendixinfo" -> return mempty -- keywords & other metadata
789+ "appendixinfo" -> skip -- keywords & other metadata
789 "bookinfo" -> addMetadataFromElement e
790 "bookinfo" -> addMetadataFromElement e
790 "article" -> modify (\st -> st{ dbBook = False }) >>
791 "article" -> modify (\st -> st{ dbBook = False }) >>
791 addMetadataFromElement e >> getBlocks e
792 addMetadataFromElement e >> getBlocks e
@@ -802,8 +803,12 @@ parseBlock (Elem e) =
802 "?xml" -> return mempty
803 "?xml" -> return mempty
803 "title" -> return mempty -- handled in parent element
804 "title" -> return mempty -- handled in parent element
804 "subtitle" -> return mempty -- handled in parent element
805 "subtitle" -> return mempty -- handled in parent element
805− _ -> getBlocks e
806+ _ -> skip >> getBlocks e
807+ where skip = do
808+ lift $ report $ IgnoredElement $ qName (elName e)
809+ return mempty
810+
806− where parseMixed container conts = do
811+ parseMixed container conts = do
807 let (ils,rest) = break isBlockElement conts
812 let (ils,rest) = break isBlockElement conts
808 ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
813 ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
809 let p = if ils' == mempty then mempty else container ils'
814 let p = if ils' == mempty then mempty else container ils'
@@ -1000,13 +1005,17 @@ parseInline (Elem e) =
1000 "footnote" -> (note . mconcat) <$>
1005 "footnote" -> (note . mconcat) <$>
1001 mapM parseBlock (elContent e)
1006 mapM parseBlock (elContent e)
1002 "title" -> return mempty
1007 "title" -> return mempty
1003− "affiliation" -> return mempty
1008+ "affiliation" -> skip
1004 -- Note: this isn't a real docbook tag; it's what we convert
1009 -- Note: this isn't a real docbook tag; it's what we convert
1005 -- <?asciidor-br?> to in handleInstructions, above. A kludge to
1010 -- <?asciidor-br?> to in handleInstructions, above. A kludge to
1006 -- work around xml-light's inability to parse an instruction.
1011 -- work around xml-light's inability to parse an instruction.
1007 "br" -> return linebreak
1012 "br" -> return linebreak
1008− _ -> innerInlines
1013+ _ -> skip >> innerInlines
1014+ where skip = do
1015+ lift $ report $ IgnoredElement $ qName (elName e)
1016+ return mempty
1017+
1009− where innerInlines = (trimInlines . mconcat) <$>
1018+ innerInlines = (trimInlines . mconcat) <$>
1010 mapM parseInline (elContent e)
1019 mapM parseInline (elContent e)
1011 codeWithLang = do
1020 codeWithLang = do
1012 let classes' = case attrValue "language" e of
1021 let classes' = case attrValue "language" e of