mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-28 17:20:47 +08:00
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:
committed by
John MacFarlane
parent
b4f71f7ef0
commit
84e39ff36f
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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.
Reference in New Issue
Block a user