diff --git a/src/Text/Pandoc/Readers/ODT/ContentReader.hs b/src/Text/Pandoc/Readers/ODT/ContentReader.hs index 9efaa1906..2e192f3e3 100644 --- a/src/Text/Pandoc/Readers/ODT/ContentReader.hs +++ b/src/Text/Pandoc/Readers/ODT/ContentReader.hs @@ -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 diff --git a/test/Tests/Readers/ODT.hs b/test/Tests/Readers/ODT.hs index fe59f73cf..0e39839aa 100644 --- a/test/Tests/Readers/ODT.hs +++ b/test/Tests/Readers/ODT.hs @@ -177,6 +177,7 @@ namesOfTestsComparingToNative = [ "blockquote" , "orderedListSimple" , "orderedListHeader" , "preformattedText" + , "preformattedTextParentStyle" , "referenceToChapter" , "referenceToListItem" , "referenceToText" diff --git a/test/odt/native/preformattedTextParentStyle.native b/test/odt/native/preformattedTextParentStyle.native new file mode 100644 index 000000000..99c54b4a6 --- /dev/null +++ b/test/odt/native/preformattedTextParentStyle.native @@ -0,0 +1,4 @@ +[ CodeBlock + ( "" , [] , [] ) + "void main() {\n printf(\"Hello world\");\n}" +] diff --git a/test/odt/odt/preformattedTextParentStyle.odt b/test/odt/odt/preformattedTextParentStyle.odt new file mode 100644 index 000000000..48ebff5e7 Binary files /dev/null and b/test/odt/odt/preformattedTextParentStyle.odt differ