diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2014-08-11 22:00:03 -0400 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2014-08-11 23:08:33 -0400 |
commit | 3e32cd5bb1ed4f5a5f408a7f676b323318bdb945 (patch) | |
tree | 62991c969b0defce2bfb58df1754779e1724149d /src/Text | |
parent | bca74a2bd0187c0dab522e768d7d18f8f53abfa9 (diff) | |
download | pandoc-3e32cd5bb1ed4f5a5f408a7f676b323318bdb945.tar.gz |
Docx reader: Use dropcap state.
If we get to a dropcap, we keep hold the inlines until the next
paragraph, and combine it there.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 085ee01fc..d6d5f317c 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -105,11 +105,15 @@ readDocx opts bytes = Left _ -> error $ "couldn't parse docx file" data DState = DState { docxAnchorMap :: M.Map String String - , docxMediaBag :: MediaBag } + , docxMediaBag :: MediaBag + , docxDropCap :: [Inline] + } instance Default DState where def = DState { docxAnchorMap = M.empty - , docxMediaBag = mempty } + , docxMediaBag = mempty + , docxDropCap = [] + } data DEnv = DEnv { docxOptions :: ReaderOptions , docxInHeaderBlock :: Bool } @@ -457,13 +461,17 @@ bodyPartToBlocks (Paragraph pPr parparts) return [hdr] bodyPartToBlocks (Paragraph pPr parparts) = do ils <- parPartsToInlines parparts >>= (return . normalizeSpaces) - case ils of - [] -> return [] - _ -> do - return $ - rebuild - (parStyleToContainers pPr) - [Para ils] + dropIls <- gets docxDropCap + let ils' = dropIls ++ ils + if dropCap pPr + then do modify $ \s -> s { docxDropCap = ils' } + return [] + else do modify $ \s -> s { docxDropCap = [] } + return $ case ils' of + [] -> [] + _ -> rebuild + (parStyleToContainers pPr) + [Para $ ils'] bodyPartToBlocks (ListItem pPr numId lvl levelInfo parparts) = do let kvs = case levelInfo of |