From f1e64ee0be2dceaa8947f89221f4d2bdf0d0e673 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 20 May 2025 10:18:32 -0700 Subject: [PATCH] RST writer: don't emit alignment markers in grid tables. Closes #10857. --- src/Text/Pandoc/Writers/RST.hs | 3 ++- test/tables-rstsubset.native | 16 ++++++++-------- test/tables.rst | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 01deeb969..76c8d6fd0 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -339,7 +339,8 @@ blockToRST (Table _attrs blkCapt specs thead tbody tfoot) = do modify $ \st -> st{ stOptions = oldOpts } return result opts <- gets stOptions - let renderGrid = gridTable opts blocksToDoc specs thead tbody tfoot + let specs' = map (\(_,width) -> (AlignDefault, width)) specs + renderGrid = gridTable opts blocksToDoc specs' thead tbody tfoot isSimple = all (== 0) widths && length widths > 1 renderSimple = do tbl' <- simpleTable opts blocksToDoc headers rows diff --git a/test/tables-rstsubset.native b/test/tables-rstsubset.native index 7e63f2f20..d9fd4342a 100644 --- a/test/tables-rstsubset.native +++ b/test/tables-rstsubset.native @@ -462,10 +462,10 @@ , Str "lines." ] ]) - [ ( AlignCenter , ColWidth 0.15 ) - , ( AlignLeft , ColWidth 0.1375 ) - , ( AlignRight , ColWidth 0.1625 ) - , ( AlignLeft , ColWidth 0.35 ) + [ ( AlignDefault , ColWidth 0.15 ) + , ( AlignDefault , ColWidth 0.1375 ) + , ( AlignDefault , ColWidth 0.1625 ) + , ( AlignDefault , ColWidth 0.35 ) ] (TableHead ( "" , [] , [] ) @@ -606,10 +606,10 @@ , Table ( "" , [] , [] ) (Caption Nothing []) - [ ( AlignCenter , ColWidth 0.15 ) - , ( AlignLeft , ColWidth 0.1375 ) - , ( AlignRight , ColWidth 0.1625 ) - , ( AlignLeft , ColWidth 0.35 ) + [ ( AlignDefault , ColWidth 0.15 ) + , ( AlignDefault , ColWidth 0.1375 ) + , ( AlignDefault , ColWidth 0.1625 ) + , ( AlignDefault , ColWidth 0.35 ) ] (TableHead ( "" , [] , [] ) diff --git a/test/tables.rst b/test/tables.rst index 8776c2df9..4b475c0b6 100644 --- a/test/tables.rst +++ b/test/tables.rst @@ -39,7 +39,7 @@ Multiline table with caption: +-----------+----------+------------+---------------------------+ | Centered | Left | Right | Default aligned | | Header | Aligned | Aligned | | - +:=========:+:=========+===========:+:==========================+ + +===========+==========+============+===========================+ | First | row | 12.0 | Example of a row that | | | | | spans multiple lines. | +-----------+----------+------------+---------------------------+ @@ -53,7 +53,7 @@ Multiline table without caption: +-----------+----------+------------+---------------------------+ | Centered | Left | Right | Default aligned | | Header | Aligned | Aligned | | -+:=========:+:=========+===========:+:==========================+ ++===========+==========+============+===========================+ | First | row | 12.0 | Example of a row that | | | | | spans multiple lines. | +-----------+----------+------------+---------------------------+