From 465c28d28e1017040a41653edb6248056f178d3b Mon Sep 17 00:00:00 2001 From: Milan Bracke Date: Thu, 24 Jun 2021 09:27:28 +0200 Subject: Docx reader: fix handling of empty fields Some fields only have an instrText and no content, Pandoc didn't understand these, causing other fields to be misunderstood because it seemed like a field was still open when it wasn't. --- src/Text/Pandoc/Readers/Docx/Parse.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index a97d4b3d1..0021741ed 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -844,6 +844,10 @@ elemToParPart ns element FldCharFieldInfo info : ancestors | fldCharType == "separate" -> do modify $ \st -> st {stateFldCharState = FldCharContent info [] : ancestors} return NullParPart + -- Some fields have no content, since Pandoc doesn't understand any of those fields, we can just close it. + FldCharFieldInfo _ : ancestors | fldCharType == "end" -> do + modify $ \st -> st {stateFldCharState = ancestors} + return NullParPart [FldCharContent info children] | fldCharType == "end" -> do modify $ \st -> st {stateFldCharState = []} return $ Field info $ reverse children -- cgit v1.2.3