@@ -85,7 +85,7 @@ import Text.Pandoc.Readers.Docx.Reducible
8585import Text.Pandoc.Shared
8686import Text.Pandoc.MediaBag (insertMedia, MediaBag)
8787import Data.Maybe (isJust)
88−import Data.List (delete, stripPrefix, (\\), intersect)
88+import Data.List (delete, stripPrefix, (\\), intersect, isPrefixOf)
8989import Data.Monoid
9090import Text.TeXMath (writeTeX)
9191import Data.Default (Default)
@@ -471,7 +471,6 @@ bodyPartToBlocks (Paragraph pPr parparts)
471471 , Just n <- isHeaderClass c = do
472472 ils <- local (\s-> s{docxInHeaderBlock=True}) $
473473 (concatReduce <$> mapM parPartToInlines parparts)
474−
475474 makeHeaderAnchor $
476475 headerWith ("", delete ("Heading" ++ show n) cs, []) n ils
477476 | otherwise = do
@@ -562,9 +561,10 @@ docxToOutput opts (Docx (Document _ body)) =
562561 evalDocxContext (bodyToOutput body) dEnv def
563562
564563isHeaderClass :: String -> Maybe Int
565−isHeaderClass s | Just s' <- stripPrefix "Heading" s =
566− case reads s' :: [(Int, String)] of
567− [] -> Nothing
568− ((n, "") : []) -> Just n
569− _ -> Nothing
564+isHeaderClass s | (pref:_) <- filter (\h -> isPrefixOf h s) headerPrefixes
565+ , Just s' <- stripPrefix pref s =
566+ case reads s' :: [(Int, String)] of
567+ [] -> Nothing
568+ ((n, "") : []) -> Just n
569+ _ -> Nothing
570570isHeaderClass _ = Nothing