aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-02-01 17:04:38 -0800
committerJohn MacFarlane <[email protected]>2025-02-01 17:04:38 -0800
commit1470b3a5732f2e48bd97fe4c62cdf11e64c02e73 (patch)
treefd8bf97d90c3424c8298c4466a027f5f7fb968cf /src
parentc0dc9538255b1ec316129e37d88dedeba982d302 (diff)
DocBook reader: better handle formalpara, example, and sidebar.
Include identifiers and titles in each case. The code should be credited to @tombolano. Closes #8666.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
index 10cea2721..c26cfff9d 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -797,6 +797,9 @@ blockTags = Set.fromList $
admonitionTags :: [Text]
admonitionTags = ["caution","danger","important","note","tip","warning"]
+titledBlockElements :: [Text]
+titledBlockElements = ["example", "formalpara", "sidebar"]
+
-- Trim leading and trailing newline characters
trimNl :: Text -> Text
trimNl = T.dropAround (== '\n')
@@ -860,12 +863,6 @@ parseBlock (Elem e) =
"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
- Just t -> divWith ("",["formalpara-title"],[]) .
- para . strong <$> getInlines t
- Nothing -> return mempty
- (tit <>) <$> parseMixed para (elContent e)
"simpara" -> parseMixed para (elContent e)
"ackno" -> parseMixed para (elContent e)
"epigraph" -> parseBlockquote
@@ -910,6 +907,7 @@ parseBlock (Elem e) =
"refsect2" -> sect 2
"refsect3" -> sect 3
"refsection" -> gets dbSectionLevel >>= sect . (+1)
+ l | l `elem` titledBlockElements -> parseAdmonition l
l | l `elem` admonitionTags -> parseAdmonition l
"area" -> skip
"areaset" -> skip
@@ -981,6 +979,7 @@ parseBlock (Elem e) =
lift $ report $ IgnoredElement name
return mempty
+
compactSpacing = case attrValue "spacing" e of
"compact" -> True
_ -> False