diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2014-09-06 07:53:29 -0400 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2014-09-06 07:53:29 -0400 |
commit | 132814aeb68fc7f50c2ab8370339e0c5ffb7793d (patch) | |
tree | 40d9e6b4efedaf6f663e195dc1e88106180aaf41 /src/Text/Pandoc | |
parent | f56e0e958a1f2d1332bdb350205ee38afcaf4a1c (diff) | |
download | pandoc-132814aeb68fc7f50c2ab8370339e0c5ffb7793d.tar.gz |
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.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 8 |
1 files changed, 4 insertions, 4 deletions
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 |