aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-06-09 12:17:23 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-06-09 12:17:23 -0700
commit01bbb52628d8151d9f624fab4a95fa9f8a54a1c2 (patch)
treed9e0fa79311e831a30e02babdc893f70e3a781d7 /src/Text
parent96fae8da507b44466133e759a297baeb52566d63 (diff)
downloadpandoc-01bbb52628d8151d9f624fab4a95fa9f8a54a1c2.tar.gz
DocBook reader: Issue IgnoredElement warnings.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
index c1d092a70..9352cd938 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -24,8 +24,9 @@ import Data.Text (Text)
import qualified Data.Text as T
import Text.HTML.TagSoup.Entity (lookupEntity)
import Text.Pandoc.Builder
-import Text.Pandoc.Class (PandocMonad)
+import Text.Pandoc.Class (PandocMonad, report)
import Text.Pandoc.Options
+import Text.Pandoc.Logging (LogMessage(..))
import Text.Pandoc.Shared (crFilter, safeRead)
import Text.TeXMath (readMathML, writeTeX)
import Text.XML.Light
@@ -690,8 +691,8 @@ parseBlock (Text (CData _ s _)) = if all isSpace s
parseBlock (CRef x) = return $ plain $ str $ map toUpper x
parseBlock (Elem e) =
case qName (elName e) of
- "toc" -> return mempty -- skip TOC, since in pandoc it's autogenerated
- "index" -> return mempty -- skip index, since page numbers meaningless
+ "toc" -> skip -- skip TOC, since in pandoc it's autogenerated
+ "index" -> skip -- skip index, since page numbers meaningless
"para" -> parseMixed para (elContent e)
"formalpara" -> do
tit <- case filterChild (named "title") e of
@@ -703,9 +704,9 @@ parseBlock (Elem e) =
"ackno" -> parseMixed para (elContent e)
"epigraph" -> parseBlockquote
"blockquote" -> parseBlockquote
- "attribution" -> return mempty
- "titleabbrev" -> return mempty
- "authorinitials" -> return mempty
+ "attribution" -> skip
+ "titleabbrev" -> skip
+ "authorinitials" -> skip
"bibliography" -> sect 0
"bibliodiv" -> sect 1
"biblioentry" -> parseMixed para (elContent e)
@@ -745,9 +746,9 @@ parseBlock (Elem e) =
<$> getBlocks e
"warning" -> blockQuote . (para (strong $ str "Warning") <>)
<$> getBlocks e
- "area" -> return mempty
- "areaset" -> return mempty
- "areaspec" -> return mempty
+ "area" -> skip
+ "areaset" -> skip
+ "areaspec" -> skip
"qandadiv" -> gets dbSectionLevel >>= sect . (+1)
"question" -> addToStart (strong (str "Q:") <> str " ") <$> getBlocks e
"answer" -> addToStart (strong (str "A:") <> str " ") <$> getBlocks e
@@ -770,22 +771,22 @@ parseBlock (Elem e) =
"variablelist" -> definitionList <$> deflistitems
"figure" -> getFigure e
"mediaobject" -> para <$> getMediaobject e
- "caption" -> return mempty
+ "caption" -> skip
"info" -> addMetadataFromElement e
"articleinfo" -> addMetadataFromElement e
- "sectioninfo" -> return mempty -- keywords & other metadata
- "refsectioninfo" -> return mempty -- keywords & other metadata
- "refsect1info" -> return mempty -- keywords & other metadata
- "refsect2info" -> return mempty -- keywords & other metadata
- "refsect3info" -> return mempty -- keywords & other metadata
- "sect1info" -> return mempty -- keywords & other metadata
- "sect2info" -> return mempty -- keywords & other metadata
- "sect3info" -> return mempty -- keywords & other metadata
- "sect4info" -> return mempty -- keywords & other metadata
- "sect5info" -> return mempty -- keywords & other metadata
- "chapterinfo" -> return mempty -- keywords & other metadata
- "glossaryinfo" -> return mempty -- keywords & other metadata
- "appendixinfo" -> return mempty -- keywords & other metadata
+ "sectioninfo" -> skip -- keywords & other metadata
+ "refsectioninfo" -> skip -- keywords & other metadata
+ "refsect1info" -> skip -- keywords & other metadata
+ "refsect2info" -> skip -- keywords & other metadata
+ "refsect3info" -> skip -- keywords & other metadata
+ "sect1info" -> skip -- keywords & other metadata
+ "sect2info" -> skip -- keywords & other metadata
+ "sect3info" -> skip -- keywords & other metadata
+ "sect4info" -> skip -- keywords & other metadata
+ "sect5info" -> skip -- keywords & other metadata
+ "chapterinfo" -> skip -- keywords & other metadata
+ "glossaryinfo" -> skip -- keywords & other metadata
+ "appendixinfo" -> skip -- keywords & other metadata
"bookinfo" -> addMetadataFromElement e
"article" -> modify (\st -> st{ dbBook = False }) >>
addMetadataFromElement e >> getBlocks e
@@ -802,8 +803,12 @@ parseBlock (Elem e) =
"?xml" -> return mempty
"title" -> return mempty -- handled in parent element
"subtitle" -> return mempty -- handled in parent element
- _ -> getBlocks e
- where parseMixed container conts = do
+ _ -> skip >> getBlocks e
+ where skip = do
+ lift $ report $ IgnoredElement $ qName (elName e)
+ return mempty
+
+ parseMixed container conts = do
let (ils,rest) = break isBlockElement conts
ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
let p = if ils' == mempty then mempty else container ils'
@@ -1000,13 +1005,17 @@ parseInline (Elem e) =
"footnote" -> (note . mconcat) <$>
mapM parseBlock (elContent e)
"title" -> return mempty
- "affiliation" -> return mempty
+ "affiliation" -> skip
-- Note: this isn't a real docbook tag; it's what we convert
-- <?asciidor-br?> to in handleInstructions, above. A kludge to
-- work around xml-light's inability to parse an instruction.
"br" -> return linebreak
- _ -> innerInlines
- where innerInlines = (trimInlines . mconcat) <$>
+ _ -> skip >> innerInlines
+ where skip = do
+ lift $ report $ IgnoredElement $ qName (elName e)
+ return mempty
+
+ innerInlines = (trimInlines . mconcat) <$>
mapM parseInline (elContent e)
codeWithLang = do
let classes' = case attrValue "language" e of