@@ -100,7 +100,7 @@ data WriterEnv = WriterEnv{ envTextProperties :: [Element]
100100 , envInDel :: Bool
101101 , envChangesAuthor :: String
102102 , envChangesDate :: String
103−
103+ , envPrintWidth :: Integer
104104 }
105105
106106defaultWriterEnv :: WriterEnv
@@ -112,6 +112,7 @@ defaultWriterEnv = WriterEnv{ envTextProperties = []
112112 , envInDel = False
113113 , envChangesAuthor = "unknown"
114114 , envChangesDate = "1969-12-31T19:00:00Z"
115+ , envPrintWidth = 1
115116 }
116117
117118data WriterState = WriterState{
@@ -122,7 +123,6 @@ data WriterState = WriterState{
122123 , stLists :: [ListMarker]
123124 , stInsId :: Int
124125 , stDelId :: Int
125− , stPrintWidth :: Integer
126126 , stStyleMaps :: StyleMaps
127127 , stFirstPara :: Bool
128128 , stTocTitle :: [Inline]
@@ -139,7 +139,6 @@ defaultWriterState = WriterState{
139139 , stLists = [NoMarker]
140140 , stInsId = 1
141141 , stDelId = 1
142− , stPrintWidth = 1
143142 , stStyleMaps = defaultStyleMaps
144143 , stFirstPara = False
145144 , stTocTitle = normalizeInlines [Str "Table of Contents"]
@@ -259,8 +258,7 @@ writeDocx opts doc@(Pandoc meta _) = do
259258 metaValueToInlines <$> lookupMeta "toc-title" meta
260259
261260 let initialSt = defaultWriterState {
262− stPrintWidth = (maybe 420 (\x -> quot x 20) pgContentWidth)
263− , stStyleMaps = styleMaps
261+ stStyleMaps = styleMaps
264262 , stTocTitle = tocTitle
265263 }
266264
@@ -273,6 +271,7 @@ writeDocx opts doc@(Pandoc meta _) = do
273271 envRTL = isRTLmeta
274272 , envChangesAuthor = fromMaybe "unknown" username
275273 , envChangesDate = formatTime defaultTimeLocale "%FT%XZ" utctime
274+ , envPrintWidth = (maybe 420 (\x -> quot x 20) pgContentWidth)
276275 }
277276
278277
@@ -1171,7 +1170,7 @@ inlineToOpenXML' opts (Link _ txt (src,_)) = do
11711170 return [ mknode "w:hyperlink" [("r:id",id')] contents ]
11721171inlineToOpenXML' opts (Image attr alt (src, _)) = do
11731172 -- first, check to see if we've already done this image
1174− pageWidth <- gets stPrintWidth
1173+ pageWidth <- asks envPrintWidth
11751174 imgs <- gets stImages
11761175 case M.lookup src imgs of
11771176 Just (_,_,_,elt,_) -> return [elt]