Odt reader: Support Preformatted Text from pandoc writer

pandoc generates a separate style class like P123 for each paragraph,
inheriting the desired style using `parent-style-name`.

Previously, we did not support that but it is pretty easy to add.
Though for simplicity this fix does not extend to finding the parent
style recursively when deeper hierarchies are involved.
This commit is contained in:
Jan Tojnar
2026-02-15 01:59:26 +01:00
committed by John MacFarlane
parent b4f71f7ef0
commit 84e39ff36f
4 changed files with 9 additions and 3 deletions
+4 -3
View File
@@ -656,13 +656,14 @@ read_paragraph = matchingElement NsText "p" $
liftA CombiningBlocks $ proc blocks -> do
fStyle <- readStyleByName -< blocks
case fStyle of
Right (styleName, _) | isPreformattedStyle styleName -> do
Right style | isPreformattedStyle style -> do
liftA (codeBlock . stringify) $ matchParagraphContent -< blocks
_ ->
constructPara $ liftA para $ withNewStyle matchParagraphContent -< blocks
where
isPreformattedStyle :: StyleName -> Bool
isPreformattedStyle "Preformatted_20_Text" = True
isPreformattedStyle :: (StyleName, Style) -> Bool
isPreformattedStyle ("Preformatted_20_Text", _) = True
isPreformattedStyle (_, Style { styleParentName = Just "Preformatted_20_Text" }) = True
isPreformattedStyle _ = False
+1
View File
@@ -177,6 +177,7 @@ namesOfTestsComparingToNative = [ "blockquote"
, "orderedListSimple"
, "orderedListHeader"
, "preformattedText"
, "preformattedTextParentStyle"
, "referenceToChapter"
, "referenceToListItem"
, "referenceToText"
@@ -0,0 +1,4 @@
[ CodeBlock
( "" , [] , [] )
"void main() {\n printf(\"Hello world\");\n}"
]
Binary file not shown.