diff options
| author | John MacFarlane <[email protected]> | 2025-02-01 17:04:38 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-02-01 17:04:38 -0800 |
| commit | 1470b3a5732f2e48bd97fe4c62cdf11e64c02e73 (patch) | |
| tree | fd8bf97d90c3424c8298c4466a027f5f7fb968cf /src | |
| parent | c0dc9538255b1ec316129e37d88dedeba982d302 (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.hs | 11 |
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 |
