aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs123
-rw-r--r--test/docx/golden/block_quotes.docxbin10096 -> 9985 bytes
-rw-r--r--test/docx/golden/codeblock.docxbin9912 -> 9800 bytes
-rw-r--r--test/docx/golden/comments.docxbin10249 -> 10138 bytes
-rw-r--r--test/docx/golden/custom_style_no_reference.docxbin10012 -> 9900 bytes
-rw-r--r--test/docx/golden/custom_style_preserve.docxbin10642 -> 10530 bytes
-rw-r--r--test/docx/golden/custom_style_reference.docxbin12388 -> 12552 bytes
-rw-r--r--test/docx/golden/definition_list.docxbin9911 -> 9800 bytes
-rw-r--r--test/docx/golden/document-properties-short-desc.docxbin9918 -> 9807 bytes
-rw-r--r--test/docx/golden/document-properties.docxbin10403 -> 10292 bytes
-rw-r--r--test/docx/golden/headers.docxbin10051 -> 9940 bytes
-rw-r--r--test/docx/golden/image.docxbin26792 -> 26682 bytes
-rw-r--r--test/docx/golden/inline_code.docxbin9850 -> 9740 bytes
-rw-r--r--test/docx/golden/inline_formatting.docxbin10030 -> 9920 bytes
-rw-r--r--test/docx/golden/inline_images.docxbin26790 -> 26680 bytes
-rw-r--r--test/docx/golden/link_in_notes.docxbin10072 -> 9961 bytes
-rw-r--r--test/docx/golden/links.docxbin10243 -> 10133 bytes
-rw-r--r--test/docx/golden/lists.docxbin10309 -> 10199 bytes
-rw-r--r--test/docx/golden/lists_continuing.docxbin10105 -> 9994 bytes
-rw-r--r--test/docx/golden/lists_div_bullets.docxbin9958 -> 9847 bytes
-rw-r--r--test/docx/golden/lists_multiple_initial.docxbin10187 -> 10076 bytes
-rw-r--r--test/docx/golden/lists_restarting.docxbin10103 -> 9992 bytes
-rw-r--r--test/docx/golden/nested_anchors_in_header.docxbin10243 -> 10133 bytes
-rw-r--r--test/docx/golden/notes.docxbin10019 -> 9908 bytes
-rw-r--r--test/docx/golden/raw-blocks.docxbin9951 -> 9840 bytes
-rw-r--r--test/docx/golden/raw-bookmarks.docxbin10085 -> 9974 bytes
-rw-r--r--test/docx/golden/table_one_row.docxbin9940 -> 9829 bytes
-rw-r--r--test/docx/golden/table_with_list_cell.docxbin10259 -> 10148 bytes
-rw-r--r--test/docx/golden/tables-default-widths.docxbin10286 -> 10175 bytes
-rw-r--r--test/docx/golden/tables.docxbin10301 -> 10190 bytes
-rw-r--r--test/docx/golden/tables_separated_with_rawblock.docxbin9936 -> 9825 bytes
-rw-r--r--test/docx/golden/track_changes_deletion.docxbin9894 -> 9783 bytes
-rw-r--r--test/docx/golden/track_changes_insertion.docxbin9878 -> 9766 bytes
-rw-r--r--test/docx/golden/track_changes_move.docxbin9911 -> 9800 bytes
-rw-r--r--test/docx/golden/track_changes_scrubbed_metadata.docxbin10023 -> 9912 bytes
-rw-r--r--test/docx/golden/unicode.docxbin9836 -> 9726 bytes
-rw-r--r--test/docx/golden/verbatim_subsuper.docxbin9883 -> 9773 bytes
37 files changed, 99 insertions, 24 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index 1a2cc79a4..e89ec4801 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -28,7 +28,7 @@ import Codec.Archive.Zip
toEntry,
Entry(eRelativePath) )
import Control.Applicative ((<|>))
-import Control.Monad (MonadPlus(mplus), unless, when)
+import Control.Monad (MonadPlus(mplus), unless, when, foldM)
import Control.Monad.Except (catchError, throwError)
import Control.Monad.Reader
( asks, MonadReader(local), MonadTrans(lift), ReaderT(runReaderT) )
@@ -508,30 +508,105 @@ writeDocx opts doc = do
-- adds references to footnotes or endnotes we don't have...
-- we do, however, copy some settings over from reference
let settingsPath = "word/settings.xml"
- settingsList = [ "zoom"
- , "mirrorMargins"
+
+ settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime
+ -- note: these must go in the following order:
+ [ "writeProtection"
+ , "view"
+ , "zoom"
+ , "removePersonalInformation"
+ , "removeDateAndTime"
+ , "doNotDisplayPageBoundaries"
+ , "displayBackgroundShape"
+ , "printPostScriptOverText"
+ , "printFractionalCharacterWidth"
+ , "printFormsData"
+ , "embedTrueTypeFonts"
, "embedSystemFonts"
+ , "saveSubsetFonts"
+ , "saveFormsData"
+ , "mirrorMargins"
+ , "alignBordersAndEdges"
+ , "bordersDoNotSurroundHeader"
+ , "bordersDoNotSurroundFooter"
+ , "gutterAtTop"
+ , "hideSpellingErrors"
+ , "hideGrammaticalErrors"
+ , "activeWritingStyle"
+ , "proofState"
+ , "formsDesign"
+ , "attachedTemplate"
+ , "linkStyles"
+ , "stylePaneFormatFilter"
+ , "stylePaneSortMethod"
+ , "documentType"
+ , "mailMerge"
+ , "revisionView"
+ , "trackRevisions"
, "doNotTrackMoves"
+ , "doNotTrackFormatting"
+ , "documentProtection"
+ , "autoFormatOverride"
+ , "styleLockTheme"
+ , "styleLockQFSet"
, "defaultTabStop"
+ , "autoHyphenation"
+ , "consecutiveHyphenLimit"
+ , "hyphenationZone"
+ , "doNotHyphenateCaps"
+ , "showEnvelope"
+ , "summaryLength"
+ , "clickAndTypeStyle"
+ , "defaultTableStyle"
+ , "evenAndOddHeaders"
+ , "bookFoldRevPrinting"
+ , "bookFoldPrinting"
+ , "bookFoldPrintingSheets"
, "drawingGridHorizontalSpacing"
, "drawingGridVerticalSpacing"
, "displayHorizontalDrawingGridEvery"
, "displayVerticalDrawingGridEvery"
+ , "doNotUseMarginsForDrawingGridOrigin"
+ , "drawingGridHorizontalOrigin"
+ , "drawingGridVerticalOrigin"
+ , "doNotShadeFormData"
+ , "noPunctuationKerning"
, "characterSpacingControl"
+ , "printTwoOnOne"
+ , "strictFirstAndLastChars"
+ , "noLineBreaksAfter"
+ , "noLineBreaksBefore"
, "savePreviewPicture"
- , "mathPr"
+ , "doNotValidateAgainstSchema"
+ , "saveInvalidXml"
+ , "ignoreMixedContent"
+ , "alwaysShowPlaceholderText"
+ , "doNotDemarcateInvalidXml"
+ , "saveXmlDataOnly"
+ , "useXSLTWhenSaving"
+ , "saveThroughXslt"
+ , "showXMLTags"
+ , "alwaysMergeEmptyNamespace"
+ , "updateFields"
+ , "hdrShapeDefaults"
+ , "footnotePr"
+ , "endnotePr"
+ , "compat"
+ , "docVars"
+ , "rsids"
+ , "attachedSchema"
, "themeFontLang"
+ , "clrSchemeMapping"
+ , "doNotIncludeSubdocsInStats"
+ , "doNotAutoCompressPictures"
+ , "forceUpgrade"
+ , "captions"
+ , "readModeInkLockDown"
+ , "smartTagType"
+ , "shapeDefaults"
+ , "doNotEmbedSmartTags"
, "decimalSymbol"
- , "listSeparator"
- , "autoHyphenation"
- , "consecutiveHyphenLimit"
- , "hyphenationZone"
- , "doNotHyphenateCap"
- , "evenAndOddHeaders"
- , "proofState"
- , "compat"
- ]
- settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
+ , "listSeparator" ]
let entryFromArchive arch path =
maybe (throwError $ PandocSomeError
@@ -639,17 +714,17 @@ copyChildren :: (PandocMonad m)
copyChildren refArchive distArchive path timestamp elNames = do
ref <- parseXml refArchive distArchive path
dist <- parseXml distArchive distArchive path
- let elsToCopy =
- map cleanElem $ filterChildrenName (\e -> qName e `elem` elNames) ref
- let elsToKeep =
- [e | Elem e <- elContent dist, not (any (hasSameNameAs e) elsToCopy)]
- return $ toEntry path timestamp $ renderXml dist{
- elContent = map Elem elsToKeep ++ map Elem elsToCopy
- }
+ els <- foldM (addEl ref dist) [] (reverse elNames)
+ return $ toEntry path timestamp
+ $ renderXml dist{ elContent = map cleanElem els }
where
- hasSameNameAs (Element {elName = n1}) (Element {elName = n2}) =
- qName n1 == qName n2
- cleanElem el@Element{elName=name} = el{elName=name{qURI=Nothing}}
+ addEl ref dist els name =
+ case filterChildName (hasName name) ref `mplus`
+ filterChildName (hasName name) dist of
+ Just el -> pure (el : els)
+ Nothing -> pure els
+ hasName name = (== name) . qName
+ cleanElem el@Element{elName=name} = Elem el{elName=name{qURI=Nothing}}
-- this is the lowest number used for a list numId
baseListId :: Int
diff --git a/test/docx/golden/block_quotes.docx b/test/docx/golden/block_quotes.docx
index 2c00e9ef0..e1e296f9e 100644
--- a/test/docx/golden/block_quotes.docx
+++ b/test/docx/golden/block_quotes.docx
Binary files differ
diff --git a/test/docx/golden/codeblock.docx b/test/docx/golden/codeblock.docx
index 224c3c839..62c250088 100644
--- a/test/docx/golden/codeblock.docx
+++ b/test/docx/golden/codeblock.docx
Binary files differ
diff --git a/test/docx/golden/comments.docx b/test/docx/golden/comments.docx
index 79e19d04b..eec06b554 100644
--- a/test/docx/golden/comments.docx
+++ b/test/docx/golden/comments.docx
Binary files differ
diff --git a/test/docx/golden/custom_style_no_reference.docx b/test/docx/golden/custom_style_no_reference.docx
index 561fb1534..08fb23e35 100644
--- a/test/docx/golden/custom_style_no_reference.docx
+++ b/test/docx/golden/custom_style_no_reference.docx
Binary files differ
diff --git a/test/docx/golden/custom_style_preserve.docx b/test/docx/golden/custom_style_preserve.docx
index b49f66856..e319402f2 100644
--- a/test/docx/golden/custom_style_preserve.docx
+++ b/test/docx/golden/custom_style_preserve.docx
Binary files differ
diff --git a/test/docx/golden/custom_style_reference.docx b/test/docx/golden/custom_style_reference.docx
index da579ca2f..4ff5e0d1f 100644
--- a/test/docx/golden/custom_style_reference.docx
+++ b/test/docx/golden/custom_style_reference.docx
Binary files differ
diff --git a/test/docx/golden/definition_list.docx b/test/docx/golden/definition_list.docx
index c1d06bc66..fda2f36ff 100644
--- a/test/docx/golden/definition_list.docx
+++ b/test/docx/golden/definition_list.docx
Binary files differ
diff --git a/test/docx/golden/document-properties-short-desc.docx b/test/docx/golden/document-properties-short-desc.docx
index b0d7b131f..bca089815 100644
--- a/test/docx/golden/document-properties-short-desc.docx
+++ b/test/docx/golden/document-properties-short-desc.docx
Binary files differ
diff --git a/test/docx/golden/document-properties.docx b/test/docx/golden/document-properties.docx
index 152149d89..197edc2d8 100644
--- a/test/docx/golden/document-properties.docx
+++ b/test/docx/golden/document-properties.docx
Binary files differ
diff --git a/test/docx/golden/headers.docx b/test/docx/golden/headers.docx
index f3832437d..e8865a24e 100644
--- a/test/docx/golden/headers.docx
+++ b/test/docx/golden/headers.docx
Binary files differ
diff --git a/test/docx/golden/image.docx b/test/docx/golden/image.docx
index bbc632aea..6d6b4c9f3 100644
--- a/test/docx/golden/image.docx
+++ b/test/docx/golden/image.docx
Binary files differ
diff --git a/test/docx/golden/inline_code.docx b/test/docx/golden/inline_code.docx
index 51eb15567..61bd6ba80 100644
--- a/test/docx/golden/inline_code.docx
+++ b/test/docx/golden/inline_code.docx
Binary files differ
diff --git a/test/docx/golden/inline_formatting.docx b/test/docx/golden/inline_formatting.docx
index 78391faee..bfb3a110b 100644
--- a/test/docx/golden/inline_formatting.docx
+++ b/test/docx/golden/inline_formatting.docx
Binary files differ
diff --git a/test/docx/golden/inline_images.docx b/test/docx/golden/inline_images.docx
index f43dbd9bc..b73c35e2e 100644
--- a/test/docx/golden/inline_images.docx
+++ b/test/docx/golden/inline_images.docx
Binary files differ
diff --git a/test/docx/golden/link_in_notes.docx b/test/docx/golden/link_in_notes.docx
index ac1f91c9e..c6fb930af 100644
--- a/test/docx/golden/link_in_notes.docx
+++ b/test/docx/golden/link_in_notes.docx
Binary files differ
diff --git a/test/docx/golden/links.docx b/test/docx/golden/links.docx
index 2fc3a973b..93db9c769 100644
--- a/test/docx/golden/links.docx
+++ b/test/docx/golden/links.docx
Binary files differ
diff --git a/test/docx/golden/lists.docx b/test/docx/golden/lists.docx
index 645d55ed9..d4d95b0a3 100644
--- a/test/docx/golden/lists.docx
+++ b/test/docx/golden/lists.docx
Binary files differ
diff --git a/test/docx/golden/lists_continuing.docx b/test/docx/golden/lists_continuing.docx
index e0c70ec8b..3d346262e 100644
--- a/test/docx/golden/lists_continuing.docx
+++ b/test/docx/golden/lists_continuing.docx
Binary files differ
diff --git a/test/docx/golden/lists_div_bullets.docx b/test/docx/golden/lists_div_bullets.docx
index e9830e2b4..3fdf638bb 100644
--- a/test/docx/golden/lists_div_bullets.docx
+++ b/test/docx/golden/lists_div_bullets.docx
Binary files differ
diff --git a/test/docx/golden/lists_multiple_initial.docx b/test/docx/golden/lists_multiple_initial.docx
index 43ecec97b..e374a5b64 100644
--- a/test/docx/golden/lists_multiple_initial.docx
+++ b/test/docx/golden/lists_multiple_initial.docx
Binary files differ
diff --git a/test/docx/golden/lists_restarting.docx b/test/docx/golden/lists_restarting.docx
index 9a996f345..a15f34504 100644
--- a/test/docx/golden/lists_restarting.docx
+++ b/test/docx/golden/lists_restarting.docx
Binary files differ
diff --git a/test/docx/golden/nested_anchors_in_header.docx b/test/docx/golden/nested_anchors_in_header.docx
index 2e6ba5048..5f586c7b5 100644
--- a/test/docx/golden/nested_anchors_in_header.docx
+++ b/test/docx/golden/nested_anchors_in_header.docx
Binary files differ
diff --git a/test/docx/golden/notes.docx b/test/docx/golden/notes.docx
index 1aee1887e..2fae1180c 100644
--- a/test/docx/golden/notes.docx
+++ b/test/docx/golden/notes.docx
Binary files differ
diff --git a/test/docx/golden/raw-blocks.docx b/test/docx/golden/raw-blocks.docx
index b654496af..faa83617a 100644
--- a/test/docx/golden/raw-blocks.docx
+++ b/test/docx/golden/raw-blocks.docx
Binary files differ
diff --git a/test/docx/golden/raw-bookmarks.docx b/test/docx/golden/raw-bookmarks.docx
index 4b159b79b..508a4b17b 100644
--- a/test/docx/golden/raw-bookmarks.docx
+++ b/test/docx/golden/raw-bookmarks.docx
Binary files differ
diff --git a/test/docx/golden/table_one_row.docx b/test/docx/golden/table_one_row.docx
index 1f390bad3..26aa84e43 100644
--- a/test/docx/golden/table_one_row.docx
+++ b/test/docx/golden/table_one_row.docx
Binary files differ
diff --git a/test/docx/golden/table_with_list_cell.docx b/test/docx/golden/table_with_list_cell.docx
index 47a169b39..acafc4e5e 100644
--- a/test/docx/golden/table_with_list_cell.docx
+++ b/test/docx/golden/table_with_list_cell.docx
Binary files differ
diff --git a/test/docx/golden/tables-default-widths.docx b/test/docx/golden/tables-default-widths.docx
index d1b4b9359..8a8bde8b7 100644
--- a/test/docx/golden/tables-default-widths.docx
+++ b/test/docx/golden/tables-default-widths.docx
Binary files differ
diff --git a/test/docx/golden/tables.docx b/test/docx/golden/tables.docx
index 6de810420..a5d11c27c 100644
--- a/test/docx/golden/tables.docx
+++ b/test/docx/golden/tables.docx
Binary files differ
diff --git a/test/docx/golden/tables_separated_with_rawblock.docx b/test/docx/golden/tables_separated_with_rawblock.docx
index 90727c06e..1085a0949 100644
--- a/test/docx/golden/tables_separated_with_rawblock.docx
+++ b/test/docx/golden/tables_separated_with_rawblock.docx
Binary files differ
diff --git a/test/docx/golden/track_changes_deletion.docx b/test/docx/golden/track_changes_deletion.docx
index 77ce29a8c..41d26562d 100644
--- a/test/docx/golden/track_changes_deletion.docx
+++ b/test/docx/golden/track_changes_deletion.docx
Binary files differ
diff --git a/test/docx/golden/track_changes_insertion.docx b/test/docx/golden/track_changes_insertion.docx
index 27a36ed6e..3e0380049 100644
--- a/test/docx/golden/track_changes_insertion.docx
+++ b/test/docx/golden/track_changes_insertion.docx
Binary files differ
diff --git a/test/docx/golden/track_changes_move.docx b/test/docx/golden/track_changes_move.docx
index 93141cf25..ee83709c9 100644
--- a/test/docx/golden/track_changes_move.docx
+++ b/test/docx/golden/track_changes_move.docx
Binary files differ
diff --git a/test/docx/golden/track_changes_scrubbed_metadata.docx b/test/docx/golden/track_changes_scrubbed_metadata.docx
index 9864ca04d..f3b12bfad 100644
--- a/test/docx/golden/track_changes_scrubbed_metadata.docx
+++ b/test/docx/golden/track_changes_scrubbed_metadata.docx
Binary files differ
diff --git a/test/docx/golden/unicode.docx b/test/docx/golden/unicode.docx
index e08c9ffd6..c118c7ebd 100644
--- a/test/docx/golden/unicode.docx
+++ b/test/docx/golden/unicode.docx
Binary files differ
diff --git a/test/docx/golden/verbatim_subsuper.docx b/test/docx/golden/verbatim_subsuper.docx
index adf72b847..5388d126c 100644
--- a/test/docx/golden/verbatim_subsuper.docx
+++ b/test/docx/golden/verbatim_subsuper.docx
Binary files differ