From 132814aeb68fc7f50c2ab8370339e0c5ffb7793d Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Sat, 6 Sep 2014 07:53:29 -0400 Subject: Docx Reader: Remove header class properly in other langs When we encounter one of the polyglot header styles, we want to remove that from the par styles after we convert to a header. To do that, we have to keep track of the style name, and remove it appropriately. --- src/Text/Pandoc/Readers/Docx.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 6703c779d..4b5fbfdfc 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -468,11 +468,11 @@ bodyPartToBlocks (Paragraph pPr parparts) $ codeBlock $ concatMap parPartToString parparts | (c : cs) <- filter (isJust . isHeaderClass) $ pStyle pPr - , Just n <- isHeaderClass c = do + , Just (prefix, n) <- isHeaderClass c = do ils <- local (\s-> s{docxInHeaderBlock=True}) $ (concatReduce <$> mapM parPartToInlines parparts) makeHeaderAnchor $ - headerWith ("", delete ("Heading" ++ show n) cs, []) n ils + headerWith ("", delete (prefix ++ show n) cs, []) n ils | otherwise = do ils <- concatReduce <$> mapM parPartToInlines parparts >>= (return . fromList . trimLineBreaks . normalizeSpaces . toList) @@ -560,11 +560,11 @@ docxToOutput opts (Docx (Document _ body)) = let dEnv = def { docxOptions = opts} in evalDocxContext (bodyToOutput body) dEnv def -isHeaderClass :: String -> Maybe Int +isHeaderClass :: String -> Maybe (String, Int) isHeaderClass s | (pref:_) <- filter (\h -> isPrefixOf h s) headerPrefixes , Just s' <- stripPrefix pref s = case reads s' :: [(Int, String)] of [] -> Nothing - ((n, "") : []) -> Just n + ((n, "") : []) -> Just (pref, n) _ -> Nothing isHeaderClass _ = Nothing -- cgit v1.2.3