mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Docx reader: Ensure one-row tables don't have header.
Tables in MS Word are set by default to have special first-row formatting, which pandoc uses to determine whether or not they have a header. This means that one-row tables will, by default, have only a header -- which we imagine is not what people want. This change ensures that a one-row table is not understood to be a header only. Note that this means that it is impossible to produce a header-only table from docx, even though it is legal pandoc. But we believe that in nearly all cases, it will be an accidental (and unwelcome) result Closes #3285.
This commit is contained in:
@@ -568,7 +568,8 @@ bodyPartToBlocks (Tbl _ _ _ []) =
|
||||
bodyPartToBlocks (Tbl cap _ look (r:rs)) = do
|
||||
let caption = text cap
|
||||
(hdr, rows) = case firstRowFormatting look of
|
||||
True -> (Just r, rs)
|
||||
True | null rs -> (Nothing, [r])
|
||||
| otherwise -> (Just r, rs)
|
||||
False -> (Nothing, r:rs)
|
||||
hdrCells <- case hdr of
|
||||
Just r' -> rowToBlocksList r'
|
||||
|
||||
@@ -241,6 +241,10 @@ tests = [ testGroup "inlines"
|
||||
"tables with lists in cells"
|
||||
"docx/table_with_list_cell.docx"
|
||||
"docx/table_with_list_cell.native"
|
||||
, testCompare
|
||||
"tables with one row"
|
||||
"docx/table_one_row.docx"
|
||||
"docx/table_one_row.native"
|
||||
, testCompare
|
||||
"code block"
|
||||
"docx/codeblock.docx"
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
[Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
|
||||
[]
|
||||
[[[Plain [Str "One"]]
|
||||
,[Plain [Str "Row"]]
|
||||
,[Plain [Str "Table"]]]]]
|
||||
Reference in New Issue
Block a user