aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <[email protected]>2023-04-25 14:33:19 +0200
committerJohn MacFarlane <[email protected]>2023-05-01 20:39:47 -0700
commit013351f6023a6b8b83e9f8c45d8a8fbc6dcd46f1 (patch)
tree74ccd2518a78235c6469843fc8077da1baf4042f
parenta34a4d8e4a06f3595be30dcd117bb204838335e2 (diff)
Writers.OpenDocument: fix invalid text:p inside text:p from meta
The only element in meta for which data/templates/default.opendocument allows block element content appears to be "abstract", which is already filtered out of meta' at this point, so simply convert all blocks to linebreak-separated inlines. Fixes: #8256
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs2
-rw-r--r--test/command/8256.md34
2 files changed, 35 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 1c8417c47..e844d91f7 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -255,7 +255,7 @@ writeOpenDocument opts (Pandoc meta blocks) = do
collectBlockIdent _ = []
modify $ \s -> s{ stIdentTypes = query collectBlockIdent blocks }
m <- metaToContext opts
- (blocksToOpenDocument opts)
+ (inlinesToOpenDocument opts . blocksToInlines)
(fmap chomp . inlinesToOpenDocument opts)
meta'
b <- blocksToOpenDocument opts blocks
diff --git a/test/command/8256.md b/test/command/8256.md
new file mode 100644
index 000000000..76398f607
--- /dev/null
+++ b/test/command/8256.md
@@ -0,0 +1,34 @@
+```
+% pandoc -t opendocument -s
+
+---
+title: |
+ This *is* \
+ a test
+author: Someone
+---
+
+Testing.
+^D
+<?xml version="1.0" encoding="utf-8" ?>
+<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.3">
+ <office:font-face-decls>
+ <style:font-face style:name="Courier New" style:font-family-generic="modern" style:font-pitch="fixed" svg:font-family="'Courier New'" />
+ </office:font-face-decls>
+ <office:automatic-styles>
+ <style:style style:name="T1" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
+ <style:style style:name="fr2" style:family="graphic" style:parent-style-name="Formula"><style:graphic-properties style:vertical-pos="middle" style:vertical-rel="text" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" style:wrap="none" /></style:style>
+ <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Formula"><style:graphic-properties style:vertical-pos="middle" style:vertical-rel="text" /></style:style>
+ </office:automatic-styles>
+<office:body>
+<office:text>
+<text:p text:style-name="Title">This
+<text:span text:style-name="T1">is</text:span><text:line-break />a
+test</text:p>
+<text:p text:style-name="Author">Someone</text:p>
+<text:p text:style-name="Text_20_body">Testing.</text:p>
+</office:text>
+</office:body>
+</office:document-content>
+```
+