git.iko.soy/typeable/pandoc
on master help sign in
Docx Reader: Remove header class properly in other langs
132814aJesse Rosenthal
src/Text/Pandoc/Readers/Docx.hs+4−4
@@ -468,11 +468,11 @@ bodyPartToBlocks (Paragraph pPr parparts)
468 $ codeBlock
468 $ codeBlock
469 $ concatMap parPartToString parparts
469 $ concatMap parPartToString parparts
470 | (c : cs) <- filter (isJust . isHeaderClass) $ pStyle pPr
470 | (c : cs) <- filter (isJust . isHeaderClass) $ pStyle pPr
471− , Just n <- isHeaderClass c = do
471+ , Just (prefix, n) <- isHeaderClass c = do
472 ils <- local (\s-> s{docxInHeaderBlock=True}) $
472 ils <- local (\s-> s{docxInHeaderBlock=True}) $
473 (concatReduce <$> mapM parPartToInlines parparts)
473 (concatReduce <$> mapM parPartToInlines parparts)
474 makeHeaderAnchor $
474 makeHeaderAnchor $
475− headerWith ("", delete ("Heading" ++ show n) cs, []) n ils
475+ headerWith ("", delete (prefix ++ show n) cs, []) n ils
476 | otherwise = do
476 | otherwise = do
477 ils <- concatReduce <$> mapM parPartToInlines parparts >>=
477 ils <- concatReduce <$> mapM parPartToInlines parparts >>=
478 (return . fromList . trimLineBreaks . normalizeSpaces . toList)
478 (return . fromList . trimLineBreaks . normalizeSpaces . toList)
@@ -560,11 +560,11 @@ docxToOutput opts (Docx (Document _ body)) =
560 let dEnv = def { docxOptions = opts} in
560 let dEnv = def { docxOptions = opts} in
561 evalDocxContext (bodyToOutput body) dEnv def
561 evalDocxContext (bodyToOutput body) dEnv def
562
562
563−isHeaderClass :: String -> Maybe Int
563+isHeaderClass :: String -> Maybe (String, Int)
564isHeaderClass s | (pref:_) <- filter (\h -> isPrefixOf h s) headerPrefixes
564isHeaderClass s | (pref:_) <- filter (\h -> isPrefixOf h s) headerPrefixes
565 , Just s' <- stripPrefix pref s =
565 , Just s' <- stripPrefix pref s =
566 case reads s' :: [(Int, String)] of
566 case reads s' :: [(Int, String)] of
567 [] -> Nothing
567 [] -> Nothing
568− ((n, "") : []) -> Just n
568+ ((n, "") : []) -> Just (pref, n)
569 _ -> Nothing
569 _ -> Nothing
570isHeaderClass _ = Nothing
570isHeaderClass _ = Nothing