git.iko.soy/typeable/pandoc
on master help sign in
Improve integration of settings from reference.docx.
5eb7ad7John MacFarlane
src/Text/Pandoc/Writers/Docx.hs+14−13
@@ -469,12 +469,12 @@ writeDocx opts doc = do
469 -- adds references to footnotes or endnotes we don't have...
469 -- adds references to footnotes or endnotes we don't have...
470 -- we do, however, copy some settings over from reference
470 -- we do, however, copy some settings over from reference
471 let settingsPath = "word/settings.xml"
471 let settingsPath = "word/settings.xml"
472− settingsList = [ "w:autoHyphenation"
472+ settingsList = [ "autoHyphenation"
473− , "w:consecutiveHyphenLimit"
473+ , "consecutiveHyphenLimit"
474− , "w:hyphenationZone"
474+ , "hyphenationZone"
475− , "w:doNotHyphenateCap"
475+ , "doNotHyphenateCap"
476− , "w:evenAndOddHeaders"
476+ , "evenAndOddHeaders"
477− , "w:proofState"
477+ , "proofState"
478 ]
478 ]
479 settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
479 settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
480
480
@@ -577,16 +577,17 @@ copyChildren :: (PandocMonad m)
577copyChildren refArchive distArchive path timestamp elNames = do
577copyChildren refArchive distArchive path timestamp elNames = do
578 ref <- parseXml refArchive distArchive path
578 ref <- parseXml refArchive distArchive path
579 dist <- parseXml distArchive distArchive path
579 dist <- parseXml distArchive distArchive path
580+ let elsToCopy =
581+ map cleanElem $ filterChildrenName (\e -> qName e `elem` elNames) ref
582+ let elsToKeep =
583+ [e | Elem e <- elContent dist, not (any (hasSameNameAs e) elsToCopy)]
580 return $ toEntry path timestamp $ renderXml dist{
584 return $ toEntry path timestamp $ renderXml dist{
581− elContent = elContent dist ++ copyContent ref
585+ elContent = map Elem elsToKeep ++ map Elem elsToCopy
582 }
586 }
583 where
587 where
584− strName QName{qName=name, qPrefix=prefix}
588+ hasSameNameAs (Element {elName = n1}) (Element {elName = n2}) =
585− | Just p <- prefix = p <> ":" <> name
589+ qName n1 == qName n2
586− | otherwise = name
587− shouldCopy = (`elem` elNames) . strName
588− cleanElem el@Element{elName=name} = Elem el{elName=name{qURI=Nothing}}
590+ cleanElem el@Element{elName=name} = el{elName=name{qURI=Nothing}}
589− copyContent = map cleanElem . filterChildrenName shouldCopy
590
591
591-- this is the lowest number used for a list numId
592-- this is the lowest number used for a list numId
592baseListId :: Int
593baseListId :: Int
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_preserve.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/document-properties-short-desc.docx

Binary file not shown.

test/docx/golden/document-properties.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_multiple_initial.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/raw-blocks.docx

Binary file not shown.

test/docx/golden/raw-bookmarks.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/track_changes_scrubbed_metadata.docx

Binary file not shown.

test/docx/golden/unicode.docx

Binary file not shown.

test/docx/golden/verbatim_subsuper.docx

Binary file not shown.