diff options
| author | John MacFarlane <[email protected]> | 2024-02-28 10:05:15 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-02-28 10:05:15 -0800 |
| commit | 87b07c699a5f4be6a14d45984db4898405157a65 (patch) | |
| tree | 334472cfbcf423b6be8629cc07c05adae7ad903b | |
| parent | 6f87c9e29ae27df88e12e49cd98b4b2581c5cbdd (diff) | |
Docx reader: ensure that table captions are counted.
Normally these occur outside the table element itself, but they
should still be parsed as captions in this case.
Closes #9518.
| -rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse.hs | 5 | ||||
| -rw-r--r-- | test/docx/table_captions_no_field.native | 5 | ||||
| -rw-r--r-- | test/docx/table_captions_with_field.native | 8 |
3 files changed, 8 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index 75ea68a4d..a6c1bf63a 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -793,9 +793,8 @@ elemToBodyPart ns element case pHeading parstyle of Nothing | Just (numId, lvl) <- pNumInfo parstyle -> do mkListItem parstyle numId lvl parparts - _ -> if isTable - then return $ TblCaption parstyle parparts - else return $ Paragraph parstyle parparts + _ -> return $ (if hasCaptionStyle then TblCaption else Paragraph) + parstyle parparts elemToBodyPart ns element | isElem ns "w" "tbl" element = do diff --git a/test/docx/table_captions_no_field.native b/test/docx/table_captions_no_field.native index b8f54d541..c6fb3d566 100644 --- a/test/docx/table_captions_no_field.native +++ b/test/docx/table_captions_no_field.native @@ -1,7 +1,6 @@ [Para [Str "See",Space,Str "Table",Space,Str "5.1."] -,Para [Str "Table",Space,Str "5.1"] -,Table ("",[],[]) (Caption Nothing - []) +,Table ("",[],[]) + (Caption Nothing [ Para [ Str "Table" , Space , Str "5.1" ] ]) [(AlignDefault,ColWidth 0.7605739372523825) ,(AlignDefault,ColWidth 0.11971303137380876) ,(AlignDefault,ColWidth 0.11971303137380876)] diff --git a/test/docx/table_captions_with_field.native b/test/docx/table_captions_with_field.native index 4f81ce477..034651850 100644 --- a/test/docx/table_captions_with_field.native +++ b/test/docx/table_captions_with_field.native @@ -1,6 +1,6 @@ [Para [Str "See",Space,Str "Table",Space,Str "1."] -,Para [Str "Table",Space,Str "1"] -,Table ("",[],[]) (Caption Nothing []) +,Table ("",[],[]) + (Caption Nothing [ Para [ Str "Table" , Space , Str "1" ] ]) [(AlignDefault,ColWidth 0.7605739372523825) ,(AlignDefault,ColWidth 0.11971303137380876) ,(AlignDefault,ColWidth 0.11971303137380876)] @@ -31,7 +31,8 @@ (TableFoot ("",[],[]) []) ,Header 2 ("section", [], []) [] -,Table ("",[],[]) (Caption Nothing []) +,Table ("",[],[]) + (Caption Nothing [Para [Str "Table", Space, Str "2"]]) [(AlignDefault,ColWidth 0.3332963620230701) ,(AlignDefault,ColWidth 0.3332963620230701) ,(AlignDefault,ColWidth 0.3334072759538598)] @@ -48,5 +49,4 @@ [])] (TableFoot ("",[],[]) []) -,Para [Str "Table",Space,Str "2"] ,Para [Str "See",Space,Str "Table",Space,Str "2."]] |
