@@ -432,6 +432,17 @@ writeDocx opts doc@(Pandoc meta _) = do
433 let relsEntry = toEntry relsPath epochtime $ renderXml rels
433 let relsEntry = toEntry relsPath epochtime $ renderXml rels
435+ -- we use dist archive for settings.xml, because Word sometimes
436+ -- adds references to footnotes or endnotes we don't have...
437+ -- we do, however, copy some settings over from reference
438+ let settingsPath = "word/settings.xml"
439+ settingsList = [ "w:autoHyphenation"
440+ , "w:consecutiveHyphenLimit"
441+ , "w:hyphenationZone"
442+ , "w:doNotHyphenateCap"
444+ settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
435 let entryFromArchive arch path =
446 let entryFromArchive arch path =
436 maybe (fail $ path ++ " corrupt or missing in reference docx")
447 maybe (fail $ path ++ " corrupt or missing in reference docx")
@@ -439,9 +450,6 @@ writeDocx opts doc@(Pandoc meta _) = do
439 docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml"
450 docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml"
440 themeEntry <- entryFromArchive refArchive "word/theme/theme1.xml"
451 themeEntry <- entryFromArchive refArchive "word/theme/theme1.xml"
441 fontTableEntry <- entryFromArchive refArchive "word/fontTable.xml"
452 fontTableEntry <- entryFromArchive refArchive "word/fontTable.xml"
442− -- we use dist archive for settings.xml, because Word sometimes
443− -- adds references to footnotes or endnotes we don't have...
444− settingsEntry <- entryFromArchive distArchive "word/settings.xml"
445 webSettingsEntry <- entryFromArchive refArchive "word/webSettings.xml"
453 webSettingsEntry <- entryFromArchive refArchive "word/webSettings.xml"
446 headerFooterEntries <- mapM (entryFromArchive refArchive) $
454 headerFooterEntries <- mapM (entryFromArchive refArchive) $
447 mapMaybe (fmap ("word/" ++) . extractTarget)
455 mapMaybe (fmap ("word/" ++) . extractTarget)
@@ -504,6 +512,21 @@ styleToOpenXml sm style =
504 $ backgroundColor style )
512 $ backgroundColor style )
515+copyChildren :: Archive -> Archive -> String -> Integer -> [String] -> IO Entry
516+copyChildren refArchive distArchive path timestamp elNames = do
517+ ref <- parseXml refArchive distArchive path
518+ dist <- parseXml distArchive distArchive path
519+ return $ toEntry path timestamp $ renderXml dist{
520+ elContent = elContent dist ++ copyContent ref
523+ strName QName{qName=name, qPrefix=prefix}
524+ | Just p <- prefix = p++":"++name
526+ shouldCopy = (`elem` elNames) . strName
527+ cleanElem el@Element{elName=name} = Elem el{elName=name{qURI=Nothing}}
528+ copyContent = map cleanElem . filterChildrenName shouldCopy
507-- this is the lowest number used for a list numId
530-- this is the lowest number used for a list numId
508baseListId :: Int
531baseListId :: Int
509baseListId = 1000
532baseListId = 1000