git.iko.soy/typeable/pandoc
on master help sign in
Docx writer: added framework for custom properties.
30033f4John MacFarlane
data/docx/[Content_Types].xml+1−1
@@ -1,2 +1,2 @@
1<?xml version="1.0" encoding="UTF-8"?>
1<?xml version="1.0" encoding="UTF-8"?>
2−<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml" /><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml" /><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" /><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" /><Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" /><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" /><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" /><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" /><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" /><Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" /><Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" /></Types>
2+<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml" /><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml" /><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" /><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" /><Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" /><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" /><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" /><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /><Override PartName="/docProps/custom.xml" ContentType="application/vnd.openxmlformats-officedocument.custom-properties+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" /><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" /><Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" /><Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" /></Types>
data/docx/_rels/.rels+2−1
@@ -1,2 +1,3 @@
1<?xml version="1.0" encoding="UTF-8"?>
1<?xml version="1.0" encoding="UTF-8"?>
2−<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" /><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" /></Relationships>
2+<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" /><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" /><Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" Target="docProps/custom.xml"/>
3+</Relationships>
data/docx/docProps/custom.xmlnew file+2
@@ -0,0 +1,2 @@
1+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"></Properties>
src/Text/Pandoc/Class.hs+1
@@ -629,6 +629,7 @@ getDefaultReferenceDocx = do
629 "_rels/.rels",
629 "_rels/.rels",
630 "docProps/app.xml",
630 "docProps/app.xml",
631 "docProps/core.xml",
631 "docProps/core.xml",
632+ "docProps/custom.xml",
632 "word/document.xml",
633 "word/document.xml",
633 "word/fontTable.xml",
634 "word/fontTable.xml",
634 "word/footnotes.xml",
635 "word/footnotes.xml",
src/Text/Pandoc/Writers/Docx.hs+20−1
@@ -349,6 +349,8 @@ writeDocx opts doc@(Pandoc meta _) = do
349 "application/vnd.openxmlformats-officedocument.extended-properties+xml")
349 "application/vnd.openxmlformats-officedocument.extended-properties+xml")
350 ,("/docProps/core.xml",
350 ,("/docProps/core.xml",
351 "application/vnd.openxmlformats-package.core-properties+xml")
351 "application/vnd.openxmlformats-package.core-properties+xml")
352+ ,("/docProps/custom.xml",
353+ "application/vnd.openxmlformats-officedocument.custom-properties+xml")
352 ,("/word/styles.xml",
354 ,("/word/styles.xml",
353 "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml")
355 "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml")
354 ,("/word/document.xml",
356 ,("/word/document.xml",
@@ -507,6 +509,19 @@ writeDocx opts doc@(Pandoc meta _) = do
507 ]) (formatTime defaultTimeLocale "%FT%XZ" utctime)
509 ]) (formatTime defaultTimeLocale "%FT%XZ" utctime)
508 let docPropsEntry = toEntry docPropsPath epochtime $ renderXml docProps
510 let docPropsEntry = toEntry docPropsPath epochtime $ renderXml docProps
509
511
512+ let customProperties :: [(String, String)]
513+ customProperties = [] -- FIXME
514+ let mkCustomProp (k, v) pid = mknode "property"
515+ [("fmtid","{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
516+ ,("pid", show pid)
517+ ,("name", k)] $ mknode "vt:lpwstr" [] v
518+ let customPropsPath = "docProps/custom.xml"
519+ let customProps = mknode "Properties"
520+ [("xmlns","http://schemas.openxmlformats.org/officeDocument/2006/custom-properties")
521+ ,("xmlns:vt","http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes")
522+ ] $ zipWith mkCustomProp customProperties [(2 :: Int)..]
523+ let customPropsEntry = toEntry customPropsPath epochtime $ renderXml customProps
524+
510 let relsPath = "_rels/.rels"
525 let relsPath = "_rels/.rels"
511 let rels = mknode "Relationships" [("xmlns", "http://schemas.openxmlformats.org/package/2006/relationships")]
526 let rels = mknode "Relationships" [("xmlns", "http://schemas.openxmlformats.org/package/2006/relationships")]
512 $ map (\attrs -> mknode "Relationship" attrs ())
527 $ map (\attrs -> mknode "Relationship" attrs ())
@@ -519,6 +534,9 @@ writeDocx opts doc@(Pandoc meta _) = do
519 , [("Id","rId3")
534 , [("Id","rId3")
520 ,("Type","http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties")
535 ,("Type","http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties")
521 ,("Target","docProps/core.xml")]
536 ,("Target","docProps/core.xml")]
537+ , [("Id","rId5")
538+ ,("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties")
539+ ,("Target","docProps/custom.xml")]
522 ]
540 ]
523 let relsEntry = toEntry relsPath epochtime $ renderXml rels
541 let relsEntry = toEntry relsPath epochtime $ renderXml rels
524
542
@@ -558,7 +576,8 @@ writeDocx opts doc@(Pandoc meta _) = do
558 contentTypesEntry : relsEntry : contentEntry : relEntry :
576 contentTypesEntry : relsEntry : contentEntry : relEntry :
559 footnoteRelEntry : numEntry : styleEntry : footnotesEntry :
577 footnoteRelEntry : numEntry : styleEntry : footnotesEntry :
560 commentsEntry :
578 commentsEntry :
561− docPropsEntry : docPropsAppEntry : themeEntry :
579+ docPropsEntry : docPropsAppEntry : customPropsEntry :
580+ themeEntry :
562 fontTableEntry : settingsEntry : webSettingsEntry :
581 fontTableEntry : settingsEntry : webSettingsEntry :
563 imageEntries ++ headerFooterEntries ++
582 imageEntries ++ headerFooterEntries ++
564 miscRelEntries ++ otherMediaEntries
583 miscRelEntries ++ otherMediaEntries
test/docx/golden/block_quotes.docx

Binary file not shown.

test/docx/golden/codeblock.docx

Binary file not shown.

test/docx/golden/comments.docx

Binary file not shown.

test/docx/golden/custom_style_no_reference.docx

Binary file not shown.

test/docx/golden/custom_style_reference.docx

Binary file not shown.

test/docx/golden/definition_list.docx

Binary file not shown.

test/docx/golden/headers.docx

Binary file not shown.

test/docx/golden/image.docx

Binary file not shown.

test/docx/golden/inline_code.docx

Binary file not shown.

test/docx/golden/inline_formatting.docx

Binary file not shown.

test/docx/golden/inline_images.docx

Binary file not shown.

test/docx/golden/link_in_notes.docx

Binary file not shown.

test/docx/golden/links.docx

Binary file not shown.

test/docx/golden/lists.docx

Binary file not shown.

test/docx/golden/lists_continuing.docx

Binary file not shown.

test/docx/golden/lists_restarting.docx

Binary file not shown.

test/docx/golden/nested_anchors_in_header.docx

Binary file not shown.

test/docx/golden/notes.docx

Binary file not shown.

test/docx/golden/table_one_row.docx

Binary file not shown.

test/docx/golden/table_with_list_cell.docx

Binary file not shown.

test/docx/golden/tables.docx

Binary file not shown.

test/docx/golden/track_changes_deletion.docx

Binary file not shown.

test/docx/golden/track_changes_insertion.docx

Binary file not shown.

test/docx/golden/track_changes_move.docx

Binary file not shown.

test/docx/golden/unicode.docx

Binary file not shown.

test/docx/golden/verbatim_subsuper.docx

Binary file not shown.