diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2014-06-03 12:13:31 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2014-06-03 12:13:31 -0700 |
commit | ec047aaa8c1c1e9d69b0029a2e4512785fbc15a8 (patch) | |
tree | 965c94885909e154d754b3a1aef8da1256a915b3 /src/Text | |
parent | 2842ad5a978de758d70801b5279f75b9ba679406 (diff) | |
download | pandoc-ec047aaa8c1c1e9d69b0029a2e4512785fbc15a8.tar.gz |
Docx writer: pandoc uses only numIds >= 1000 for lists.
This opens up the possiblity (with further code changes) of
preserving some numbering from the reference.docx (e.g. header
numbering.) See #1305.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index ca0892547..3d2f5d4b5 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -388,12 +388,16 @@ styleToOpenXml style = parStyle : map toStyle alltoktypes $ backgroundColor style ) ] +-- this is the lowest number used for a list numId +baseListId :: Int +baseListId = 1000 + mkNumbering :: [ListMarker] -> IO Element mkNumbering lists = do elts <- mapM mkAbstractNum (ordNub lists) return $ mknode "w:numbering" [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main")] - $ elts ++ zipWith mkNum lists [1..(length lists)] + $ elts ++ zipWith mkNum lists [baseListId..(baseListId + length lists - 1)] mkNum :: ListMarker -> Int -> Element mkNum marker numid = @@ -461,7 +465,7 @@ mkLvl marker lvl = patternFor _ s = s ++ "." getNumId :: WS Int -getNumId = length `fmap` gets stLists +getNumId = ((999 +) . length) `fmap` gets stLists -- | Convert Pandoc document to two lists of -- OpenXML elements (the main document and footnotes). @@ -615,7 +619,8 @@ listItemToOpenXML :: WriterOptions -> Int -> [Block] -> WS [Element] listItemToOpenXML _ _ [] = return [] listItemToOpenXML opts numid (first:rest) = do first' <- withNumId numid $ blockToOpenXML opts first - rest' <- withNumId 1 $ blocksToOpenXML opts rest + -- baseListId is the code for no list marker: + rest' <- withNumId baseListId $ blocksToOpenXML opts rest return $ first' ++ rest' alignmentToString :: Alignment -> [Char] |