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.
This commit is contained in:
parent
f56e0e958a
commit
132814aeb6
1 changed files with 4 additions and 4 deletions
|
@ -468,11 +468,11 @@ bodyPartToBlocks (Paragraph pPr parparts)
|
||||||
$ codeBlock
|
$ codeBlock
|
||||||
$ concatMap parPartToString parparts
|
$ concatMap parPartToString parparts
|
||||||
| (c : cs) <- filter (isJust . isHeaderClass) $ pStyle pPr
|
| (c : cs) <- filter (isJust . isHeaderClass) $ pStyle pPr
|
||||||
, Just n <- isHeaderClass c = do
|
, Just (prefix, n) <- isHeaderClass c = do
|
||||||
ils <- local (\s-> s{docxInHeaderBlock=True}) $
|
ils <- local (\s-> s{docxInHeaderBlock=True}) $
|
||||||
(concatReduce <$> mapM parPartToInlines parparts)
|
(concatReduce <$> mapM parPartToInlines parparts)
|
||||||
makeHeaderAnchor $
|
makeHeaderAnchor $
|
||||||
headerWith ("", delete ("Heading" ++ show n) cs, []) n ils
|
headerWith ("", delete (prefix ++ show n) cs, []) n ils
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
ils <- concatReduce <$> mapM parPartToInlines parparts >>=
|
ils <- concatReduce <$> mapM parPartToInlines parparts >>=
|
||||||
(return . fromList . trimLineBreaks . normalizeSpaces . toList)
|
(return . fromList . trimLineBreaks . normalizeSpaces . toList)
|
||||||
|
@ -560,11 +560,11 @@ docxToOutput opts (Docx (Document _ body)) =
|
||||||
let dEnv = def { docxOptions = opts} in
|
let dEnv = def { docxOptions = opts} in
|
||||||
evalDocxContext (bodyToOutput body) dEnv def
|
evalDocxContext (bodyToOutput body) dEnv def
|
||||||
|
|
||||||
isHeaderClass :: String -> Maybe Int
|
isHeaderClass :: String -> Maybe (String, Int)
|
||||||
isHeaderClass s | (pref:_) <- filter (\h -> isPrefixOf h s) headerPrefixes
|
isHeaderClass s | (pref:_) <- filter (\h -> isPrefixOf h s) headerPrefixes
|
||||||
, Just s' <- stripPrefix pref s =
|
, Just s' <- stripPrefix pref s =
|
||||||
case reads s' :: [(Int, String)] of
|
case reads s' :: [(Int, String)] of
|
||||||
[] -> Nothing
|
[] -> Nothing
|
||||||
((n, "") : []) -> Just n
|
((n, "") : []) -> Just (pref, n)
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
isHeaderClass _ = Nothing
|
isHeaderClass _ = Nothing
|
||||||
|
|
Loading…
Reference in a new issue