diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-05-12 11:31:17 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-05-12 11:31:17 -0700 |
commit | 199c9de6548e8880d461f9482620e9ef7f64bbf1 (patch) | |
tree | 76314fd47c75a2e947c902b186f59d409dc394b1 /src/Text | |
parent | 89fa0e4a08092c2d35038b52adc700fb297f1b7f (diff) | |
download | pandoc-199c9de6548e8880d461f9482620e9ef7f64bbf1.tar.gz |
DocBook reader: Better handling tags that can have inline or block content.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/DocBook.hs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index fea9f2d0f..97bb7bdbe 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -599,15 +599,15 @@ 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 - "para" -> parsePara (elContent e) + "para" -> parseMixed para (elContent e) "formalpara" -> do tit <- case filterChild (named "title") e of Just t -> (<> str "." <> linebreak) <$> emph <$> getInlines t Nothing -> return mempty - addToStart tit <$> parsePara (elContent e) - "simpara" -> parsePara (elContent e) - "ackno" -> parsePara (elContent e) + addToStart tit <$> parseMixed para (elContent e) + "simpara" -> parseMixed para (elContent e) + "ackno" -> parseMixed para (elContent e) "epigraph" -> parseBlockquote "blockquote" -> parseBlockquote "attribution" -> return mempty @@ -616,8 +616,8 @@ parseBlock (Elem e) = "title" -> return mempty -- handled by getTitle or sect "bibliography" -> sect 0 "bibliodiv" -> sect 1 - "biblioentry" -> parsePara (elContent e) - "bibliomixed" -> parsePara (elContent e) + "biblioentry" -> parseMixed para (elContent e) + "bibliomixed" -> parseMixed para (elContent e) "glosssee" -> para . (\ils -> text "See " <> ils <> str ".") <$> getInlines e "glossseealso" -> para . (\ils -> text "See also " <> ils <> str ".") @@ -702,15 +702,15 @@ parseBlock (Elem e) = "?xml" -> return mempty _ -> getBlocks e where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e') - parsePara conts = do + parseMixed container conts = do let (ils,rest) = break isBlockElement conts ils' <- (trimInlines . mconcat) <$> mapM parseInline ils - let p = if ils' == mempty then mempty else para ils' + let p = if ils' == mempty then mempty else container ils' case rest of [] -> return p (r:rs) -> do b <- parseBlock r - x <- parsePara rs + x <- parseMixed container rs return $ p <> b <> x codeBlockWithLang classes = do let classes' = case attrValue "language" e of @@ -806,7 +806,7 @@ parseBlock (Elem e) = return $ table caption (zip aligns widths) headrows' bodyrows isEntry x = named "entry" x || named "td" x || named "th" x - parseRow = mapM getBlocks . filterChildren isEntry + parseRow = mapM (parseMixed plain . elContent) . filterChildren isEntry sect n = do isbook <- gets dbBook let n' = if isbook then n + 1 else n headerText <- case filterChild (named "title") e of |