@@ -85,7 +85,7 @@ import Text.Pandoc.Readers.Docx.Reducible
85import Text.Pandoc.Shared
85import Text.Pandoc.Shared
86import Text.Pandoc.MediaBag (insertMedia, MediaBag)
86import Text.Pandoc.MediaBag (insertMedia, MediaBag)
87import Data.Maybe (isJust)
87import Data.Maybe (isJust)
88−import Data.List (delete, stripPrefix, (\\), intersect)
88+import Data.List (delete, stripPrefix, (\\), intersect, isPrefixOf)
89import Data.Monoid
89import Data.Monoid
90import Text.TeXMath (writeTeX)
90import Text.TeXMath (writeTeX)
91import Data.Default (Default)
91import Data.Default (Default)
@@ -471,7 +471,6 @@ bodyPartToBlocks (Paragraph pPr parparts)
471 , Just n <- isHeaderClass c = do
471 , Just 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)
475 makeHeaderAnchor $
474 makeHeaderAnchor $
476 headerWith ("", delete ("Heading" ++ show n) cs, []) n ils
475 headerWith ("", delete ("Heading" ++ show n) cs, []) n ils
477 | otherwise = do
476 | otherwise = do
@@ -562,9 +561,10 @@ docxToOutput opts (Docx (Document _ body)) =
562 evalDocxContext (bodyToOutput body) dEnv def
561 evalDocxContext (bodyToOutput body) dEnv def
564isHeaderClass :: String -> Maybe Int
563isHeaderClass :: String -> Maybe Int
564+isHeaderClass s | (pref:_) <- filter (\h -> isPrefixOf h s) headerPrefixes
565−isHeaderClass s | Just s' <- stripPrefix "Heading" 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 n
569− _ -> Nothing
569+ _ -> Nothing
570isHeaderClass _ = Nothing
570isHeaderClass _ = Nothing