mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-28 17:20:47 +08:00
PPTX writer: keep tables and surrounding text on same slide (#11411)
Previously, when a slide contained bullet points before and after a table, content would be split across multiple slides or use a two-column layout that didn't preserve the source order. This change: 1. Modified `splitBlocks'` in Presentation.hs to continue accumulating content after tables instead of immediately splitting to a new slide. 2. When a slide has a table with surrounding text, use ContentSlide (single column) instead of ContentWithCaptionSlide (two columns) to preserve content order. 3. Added vertical stacking in Output.hs (shapesToElementsStacked) to properly position multiple shapes (tables + text) within a content area. Space is allocated proportionally based on content size (paragraphs and table rows). Closes #11433. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Chris Callison-Burch <ccb+github@upenn.edu>
This commit is contained in:
committed by
John MacFarlane
parent
c645e57dc8
commit
ce37e24c6a
@@ -78,6 +78,10 @@ tests = let
|
||||
def
|
||||
"pptx/tables/input.native"
|
||||
"pptx/tables/output.pptx"
|
||||
, pptxTests "table with surrounding content stays on same slide"
|
||||
def
|
||||
"pptx/table-with-surrounding-content/input.native"
|
||||
"pptx/table-with-surrounding-content/output.pptx"
|
||||
, pptxTests "table of contents"
|
||||
def{ writerTableOfContents = True }
|
||||
"pptx/slide-breaks/input.native"
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
Test that content after a table stays on the same slide.
|
||||
|
||||
```
|
||||
% pandoc -t native
|
||||
## Slide with Bullets and Table
|
||||
|
||||
- First bullet before table
|
||||
- Second bullet before table
|
||||
|
||||
| A | B |
|
||||
|---|---|
|
||||
| 1 | 2 |
|
||||
|
||||
- Third bullet after table
|
||||
- Fourth bullet after table
|
||||
^D
|
||||
[ Header
|
||||
2
|
||||
( "slide-with-bullets-and-table" , [] , [] )
|
||||
[ Str "Slide"
|
||||
, Space
|
||||
, Str "with"
|
||||
, Space
|
||||
, Str "Bullets"
|
||||
, Space
|
||||
, Str "and"
|
||||
, Space
|
||||
, Str "Table"
|
||||
]
|
||||
, BulletList
|
||||
[ [ Plain
|
||||
[ Str "First"
|
||||
, Space
|
||||
, Str "bullet"
|
||||
, Space
|
||||
, Str "before"
|
||||
, Space
|
||||
, Str "table"
|
||||
]
|
||||
]
|
||||
, [ Plain
|
||||
[ Str "Second"
|
||||
, Space
|
||||
, Str "bullet"
|
||||
, Space
|
||||
, Str "before"
|
||||
, Space
|
||||
, Str "table"
|
||||
]
|
||||
]
|
||||
]
|
||||
, Table
|
||||
( "" , [] , [] )
|
||||
(Caption Nothing [])
|
||||
[ ( AlignDefault , ColWidthDefault )
|
||||
, ( AlignDefault , ColWidthDefault )
|
||||
]
|
||||
(TableHead
|
||||
( "" , [] , [] )
|
||||
[ Row
|
||||
( "" , [] , [] )
|
||||
[ Cell
|
||||
( "" , [] , [] )
|
||||
AlignDefault
|
||||
(RowSpan 1)
|
||||
(ColSpan 1)
|
||||
[ Plain [ Str "A" ] ]
|
||||
, Cell
|
||||
( "" , [] , [] )
|
||||
AlignDefault
|
||||
(RowSpan 1)
|
||||
(ColSpan 1)
|
||||
[ Plain [ Str "B" ] ]
|
||||
]
|
||||
])
|
||||
[ TableBody
|
||||
( "" , [] , [] )
|
||||
(RowHeadColumns 0)
|
||||
[]
|
||||
[ Row
|
||||
( "" , [] , [] )
|
||||
[ Cell
|
||||
( "" , [] , [] )
|
||||
AlignDefault
|
||||
(RowSpan 1)
|
||||
(ColSpan 1)
|
||||
[ Plain [ Str "1" ] ]
|
||||
, Cell
|
||||
( "" , [] , [] )
|
||||
AlignDefault
|
||||
(RowSpan 1)
|
||||
(ColSpan 1)
|
||||
[ Plain [ Str "2" ] ]
|
||||
]
|
||||
]
|
||||
]
|
||||
(TableFoot ( "" , [] , [] ) [])
|
||||
, BulletList
|
||||
[ [ Plain
|
||||
[ Str "Third"
|
||||
, Space
|
||||
, Str "bullet"
|
||||
, Space
|
||||
, Str "after"
|
||||
, Space
|
||||
, Str "table"
|
||||
]
|
||||
]
|
||||
, [ Plain
|
||||
[ Str "Fourth"
|
||||
, Space
|
||||
, Str "bullet"
|
||||
, Space
|
||||
, Str "after"
|
||||
, Space
|
||||
, Str "table"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
```
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
[Header 2 ("slide-with-bullets-and-table",[],[]) [Str "Slide",Space,Str "with",Space,Str "Bullets",Space,Str "and",Space,Str "Table"]
|
||||
,BulletList
|
||||
[[Plain [Str "First",Space,Str "bullet",Space,Str "point",Space,Str "before",Space,Str "the",Space,Str "table"]]
|
||||
,[Plain [Str "Second",Space,Str "bullet",Space,Str "point",Space,Str "before",Space,Str "the",Space,Str "table"]]]
|
||||
,Table ("",[],[]) (Caption Nothing [])
|
||||
[(AlignDefault,ColWidthDefault)
|
||||
,(AlignDefault,ColWidthDefault)]
|
||||
(TableHead ("",[],[])
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
|
||||
[Plain [Str "Column",Space,Str "A"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
|
||||
[Plain [Str "Column",Space,Str "B"]]]])
|
||||
[(TableBody ("",[],[]) (RowHeadColumns 0)
|
||||
[]
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
|
||||
[Plain [Str "Value",Space,Str "1"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
|
||||
[Plain [Str "Value",Space,Str "2"]]]
|
||||
,Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
|
||||
[Plain [Str "Value",Space,Str "3"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
|
||||
[Plain [Str "Value",Space,Str "4"]]]])]
|
||||
(TableFoot ("",[],[]) [])
|
||||
,BulletList
|
||||
[[Plain [Str "Third",Space,Str "bullet",Space,Str "point",Space,Str "after",Space,Str "the",Space,Str "table"]]
|
||||
,[Plain [Str "Fourth",Space,Str "bullet",Space,Str "point",Space,Str "after",Space,Str "the",Space,Str "table"]]]
|
||||
,Header 2 ("second-slide-for-reference",[],[]) [Str "Second",Space,Str "Slide",Space,Str "for",Space,Str "Reference"]
|
||||
,BulletList
|
||||
[[Plain [Str "This",Space,Str "slide",Space,Str "has",Space,Str "just",Space,Str "bullets"]]
|
||||
,[Plain [Str "No",Space,Str "table",Space,Str "here"]]
|
||||
,[Plain [Str "Everything",Space,Str "stays",Space,Str "together"]]]]
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user