diff options
m--------- | data/templates | 13 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 12 |
2 files changed, 18 insertions, 7 deletions
diff --git a/data/templates b/data/templates -Subproject 095196e8d6e873ee36846ca120bf5dfd39e30a8 +Subproject 3befef257ce461ae68760004df938f3ca8397b3 diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 28f49251c..dcc2122bd 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -455,6 +455,13 @@ isHeaderContainer :: Container Block -> Bool isHeaderContainer (Container f) | Header _ _ _ <- f [] = True isHeaderContainer _ = False +trimLineBreaks :: [Inline] -> [Inline] +trimLineBreaks [] = [] +trimLineBreaks (LineBreak : ils) = trimLineBreaks ils +trimLineBreaks ils + | (LineBreak : ils') <- reverse ils = trimLineBreaks (reverse ils') +trimLineBreaks ils = ils + bodyPartToBlocks :: BodyPart -> DocxContext [Block] bodyPartToBlocks (Paragraph pPr parparts) | any isBlockCodeContainer (parStyleToContainers pPr) = @@ -467,8 +474,9 @@ bodyPartToBlocks (Paragraph pPr parparts) [CodeBlock ("", [], []) (concatMap parPartToString parparts)] bodyPartToBlocks (Paragraph pPr parparts) | any isHeaderContainer (parStyleToContainers pPr) = do - ils <- normalizeSpaces <$> local (\s -> s{docxInHeaderBlock = True}) - (parPartsToInlines parparts) + ils <- (trimLineBreaks . normalizeSpaces) <$> + local (\s -> s{docxInHeaderBlock = True}) + (parPartsToInlines parparts) let (Container hdrFun) = head $ filter isHeaderContainer (parStyleToContainers pPr) Header n attr _ = hdrFun [] hdr <- makeHeaderAnchor $ Header n attr ils |