git.iko.soy/typeable/pandoc
on master help sign in
Docx reader: Use dropcap state.

If we get to a dropcap, we keep hold the inlines until the next paragraph, and combine it there.

commit3e32cd5bb1ed4f5a5f408a7f676b323318bdb945 authorJesse Rosenthal <jrosenthal@jhu.edu> dateMon 11 Aug 2014, 22:00 (12 years ago) parentbca74a2
1 file changed+17−9
src/Text/Pandoc/Readers/Docx.hs+17−9
src/Text/Pandoc/Readers/Docx.hs+17−9
@@ -105,11 +105,15 @@ readDocx opts bytes =
105105 Left _ -> error $ "couldn't parse docx file"
106106
107107data DState = DState { docxAnchorMap :: M.Map String String
108− , docxMediaBag :: MediaBag }
108+ , docxMediaBag :: MediaBag
109+ , docxDropCap :: [Inline]
110+ }
109111
110112instance Default DState where
111113 def = DState { docxAnchorMap = M.empty
112− , docxMediaBag = mempty }
114+ , docxMediaBag = mempty
115+ , docxDropCap = []
116+ }
113117
114118data DEnv = DEnv { docxOptions :: ReaderOptions
115119 , docxInHeaderBlock :: Bool }
@@ -457,13 +461,17 @@ bodyPartToBlocks (Paragraph pPr parparts)
457461 return [hdr]
458462bodyPartToBlocks (Paragraph pPr parparts) = do
459463 ils <- parPartsToInlines parparts >>= (return . normalizeSpaces)
460− case ils of
461− [] -> return []
462− _ -> do
463− return $
464− rebuild
465− (parStyleToContainers pPr)
466− [Para ils]
464+ dropIls <- gets docxDropCap
465+ let ils' = dropIls ++ ils
466+ if dropCap pPr
467+ then do modify $ \s -> s { docxDropCap = ils' }
468+ return []
469+ else do modify $ \s -> s { docxDropCap = [] }
470+ return $ case ils' of
471+ [] -> []
472+ _ -> rebuild
473+ (parStyleToContainers pPr)
474+ [Para $ ils']
467475bodyPartToBlocks (ListItem pPr numId lvl levelInfo parparts) = do
468476 let
469477 kvs = case levelInfo of