DocBook reader: Issue IgnoredElement warnings.
This commit is contained in:
parent
96fae8da50
commit
01bbb52628
1 changed files with 37 additions and 28 deletions
|
@ -24,8 +24,9 @@ import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Text.HTML.TagSoup.Entity (lookupEntity)
|
import Text.HTML.TagSoup.Entity (lookupEntity)
|
||||||
import Text.Pandoc.Builder
|
import Text.Pandoc.Builder
|
||||||
import Text.Pandoc.Class (PandocMonad)
|
import Text.Pandoc.Class (PandocMonad, report)
|
||||||
import Text.Pandoc.Options
|
import Text.Pandoc.Options
|
||||||
|
import Text.Pandoc.Logging (LogMessage(..))
|
||||||
import Text.Pandoc.Shared (crFilter, safeRead)
|
import Text.Pandoc.Shared (crFilter, safeRead)
|
||||||
import Text.TeXMath (readMathML, writeTeX)
|
import Text.TeXMath (readMathML, writeTeX)
|
||||||
import Text.XML.Light
|
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 (CRef x) = return $ plain $ str $ map toUpper x
|
||||||
parseBlock (Elem e) =
|
parseBlock (Elem e) =
|
||||||
case qName (elName e) of
|
case qName (elName e) of
|
||||||
"toc" -> return mempty -- skip TOC, since in pandoc it's autogenerated
|
"toc" -> skip -- skip TOC, since in pandoc it's autogenerated
|
||||||
"index" -> return mempty -- skip index, since page numbers meaningless
|
"index" -> skip -- skip index, since page numbers meaningless
|
||||||
"para" -> parseMixed para (elContent e)
|
"para" -> parseMixed para (elContent e)
|
||||||
"formalpara" -> do
|
"formalpara" -> do
|
||||||
tit <- case filterChild (named "title") e of
|
tit <- case filterChild (named "title") e of
|
||||||
|
@ -703,9 +704,9 @@ parseBlock (Elem e) =
|
||||||
"ackno" -> parseMixed para (elContent e)
|
"ackno" -> parseMixed para (elContent e)
|
||||||
"epigraph" -> parseBlockquote
|
"epigraph" -> parseBlockquote
|
||||||
"blockquote" -> parseBlockquote
|
"blockquote" -> parseBlockquote
|
||||||
"attribution" -> return mempty
|
"attribution" -> skip
|
||||||
"titleabbrev" -> return mempty
|
"titleabbrev" -> skip
|
||||||
"authorinitials" -> return mempty
|
"authorinitials" -> skip
|
||||||
"bibliography" -> sect 0
|
"bibliography" -> sect 0
|
||||||
"bibliodiv" -> sect 1
|
"bibliodiv" -> sect 1
|
||||||
"biblioentry" -> parseMixed para (elContent e)
|
"biblioentry" -> parseMixed para (elContent e)
|
||||||
|
@ -745,9 +746,9 @@ parseBlock (Elem e) =
|
||||||
<$> getBlocks e
|
<$> getBlocks e
|
||||||
"warning" -> blockQuote . (para (strong $ str "Warning") <>)
|
"warning" -> blockQuote . (para (strong $ str "Warning") <>)
|
||||||
<$> getBlocks e
|
<$> getBlocks e
|
||||||
"area" -> return mempty
|
"area" -> skip
|
||||||
"areaset" -> return mempty
|
"areaset" -> skip
|
||||||
"areaspec" -> return mempty
|
"areaspec" -> skip
|
||||||
"qandadiv" -> gets dbSectionLevel >>= sect . (+1)
|
"qandadiv" -> gets dbSectionLevel >>= sect . (+1)
|
||||||
"question" -> addToStart (strong (str "Q:") <> str " ") <$> getBlocks e
|
"question" -> addToStart (strong (str "Q:") <> str " ") <$> getBlocks e
|
||||||
"answer" -> addToStart (strong (str "A:") <> str " ") <$> getBlocks e
|
"answer" -> addToStart (strong (str "A:") <> str " ") <$> getBlocks e
|
||||||
|
@ -770,22 +771,22 @@ parseBlock (Elem e) =
|
||||||
"variablelist" -> definitionList <$> deflistitems
|
"variablelist" -> definitionList <$> deflistitems
|
||||||
"figure" -> getFigure e
|
"figure" -> getFigure e
|
||||||
"mediaobject" -> para <$> getMediaobject e
|
"mediaobject" -> para <$> getMediaobject e
|
||||||
"caption" -> return mempty
|
"caption" -> skip
|
||||||
"info" -> addMetadataFromElement e
|
"info" -> addMetadataFromElement e
|
||||||
"articleinfo" -> addMetadataFromElement e
|
"articleinfo" -> addMetadataFromElement e
|
||||||
"sectioninfo" -> return mempty -- keywords & other metadata
|
"sectioninfo" -> skip -- keywords & other metadata
|
||||||
"refsectioninfo" -> return mempty -- keywords & other metadata
|
"refsectioninfo" -> skip -- keywords & other metadata
|
||||||
"refsect1info" -> return mempty -- keywords & other metadata
|
"refsect1info" -> skip -- keywords & other metadata
|
||||||
"refsect2info" -> return mempty -- keywords & other metadata
|
"refsect2info" -> skip -- keywords & other metadata
|
||||||
"refsect3info" -> return mempty -- keywords & other metadata
|
"refsect3info" -> skip -- keywords & other metadata
|
||||||
"sect1info" -> return mempty -- keywords & other metadata
|
"sect1info" -> skip -- keywords & other metadata
|
||||||
"sect2info" -> return mempty -- keywords & other metadata
|
"sect2info" -> skip -- keywords & other metadata
|
||||||
"sect3info" -> return mempty -- keywords & other metadata
|
"sect3info" -> skip -- keywords & other metadata
|
||||||
"sect4info" -> return mempty -- keywords & other metadata
|
"sect4info" -> skip -- keywords & other metadata
|
||||||
"sect5info" -> return mempty -- keywords & other metadata
|
"sect5info" -> skip -- keywords & other metadata
|
||||||
"chapterinfo" -> return mempty -- keywords & other metadata
|
"chapterinfo" -> skip -- keywords & other metadata
|
||||||
"glossaryinfo" -> return mempty -- keywords & other metadata
|
"glossaryinfo" -> skip -- keywords & other metadata
|
||||||
"appendixinfo" -> return mempty -- keywords & other metadata
|
"appendixinfo" -> skip -- keywords & other metadata
|
||||||
"bookinfo" -> addMetadataFromElement e
|
"bookinfo" -> addMetadataFromElement e
|
||||||
"article" -> modify (\st -> st{ dbBook = False }) >>
|
"article" -> modify (\st -> st{ dbBook = False }) >>
|
||||||
addMetadataFromElement e >> getBlocks e
|
addMetadataFromElement e >> getBlocks e
|
||||||
|
@ -802,8 +803,12 @@ parseBlock (Elem e) =
|
||||||
"?xml" -> return mempty
|
"?xml" -> return mempty
|
||||||
"title" -> return mempty -- handled in parent element
|
"title" -> return mempty -- handled in parent element
|
||||||
"subtitle" -> return mempty -- handled in parent element
|
"subtitle" -> return mempty -- handled in parent element
|
||||||
_ -> getBlocks e
|
_ -> skip >> getBlocks e
|
||||||
where parseMixed container conts = do
|
where skip = do
|
||||||
|
lift $ report $ IgnoredElement $ qName (elName e)
|
||||||
|
return mempty
|
||||||
|
|
||||||
|
parseMixed container conts = do
|
||||||
let (ils,rest) = break isBlockElement conts
|
let (ils,rest) = break isBlockElement conts
|
||||||
ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
|
ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
|
||||||
let p = if ils' == mempty then mempty else container ils'
|
let p = if ils' == mempty then mempty else container ils'
|
||||||
|
@ -1000,13 +1005,17 @@ parseInline (Elem e) =
|
||||||
"footnote" -> (note . mconcat) <$>
|
"footnote" -> (note . mconcat) <$>
|
||||||
mapM parseBlock (elContent e)
|
mapM parseBlock (elContent e)
|
||||||
"title" -> return mempty
|
"title" -> return mempty
|
||||||
"affiliation" -> return mempty
|
"affiliation" -> skip
|
||||||
-- Note: this isn't a real docbook tag; it's what we convert
|
-- Note: this isn't a real docbook tag; it's what we convert
|
||||||
-- <?asciidor-br?> to in handleInstructions, above. A kludge to
|
-- <?asciidor-br?> to in handleInstructions, above. A kludge to
|
||||||
-- work around xml-light's inability to parse an instruction.
|
-- work around xml-light's inability to parse an instruction.
|
||||||
"br" -> return linebreak
|
"br" -> return linebreak
|
||||||
_ -> innerInlines
|
_ -> skip >> innerInlines
|
||||||
where innerInlines = (trimInlines . mconcat) <$>
|
where skip = do
|
||||||
|
lift $ report $ IgnoredElement $ qName (elName e)
|
||||||
|
return mempty
|
||||||
|
|
||||||
|
innerInlines = (trimInlines . mconcat) <$>
|
||||||
mapM parseInline (elContent e)
|
mapM parseInline (elContent e)
|
||||||
codeWithLang = do
|
codeWithLang = do
|
||||||
let classes' = case attrValue "language" e of
|
let classes' = case attrValue "language" e of
|
||||||
|
|
Loading…
Add table
Reference in a new issue