pptx: Fix logic for choosing Comparison layout

There was a mistake in the logic used to choose between the Comparison
and Two Content layouts: if one column contained only non-text (an image
or a table) and the other contained only text, the Comparison layout was
chosen instead of the desired Two Content layout.

This commit fixes that logic:

> If either column contains text followed by non-text, use Comparison.
  Otherwise, use Two Content.

It also adds a test asserting this behaviour.
This commit is contained in:
Emily Bourke 2021-09-08 14:05:22 +01:00 committed by John MacFarlane
parent 6271b09c50
commit 0ebe65e651
13 changed files with 27 additions and 8 deletions

View file

@ -446,8 +446,10 @@ extra-source-files:
test/pptx/start-numbering-at/*.pptx
test/pptx/tables/input.native
test/pptx/tables/*.pptx
test/pptx/two-column/input.native
test/pptx/two-column/*.pptx
test/pptx/two-column/all-text/input.native
test/pptx/two-column/all-text/*.pptx
test/pptx/two-column/text-and-image/input.native
test/pptx/two-column/text-and-image/*.pptx
test/ipynb/*.in.native
test/ipynb/*.out.native
test/ipynb/*.ipynb

View file

@ -696,10 +696,11 @@ bodyBlocksToSlide _ (blk : blks) spkNotes
sldId
(ComparisonSlide [] (shapesL1, shapesL2) (shapesR1, shapesR2))
spkNotes
case (break notText blksL, break notText blksR) of
((_, []), (_, [])) -> mkTwoColumn blksL blksR
(([], _), ([], _)) -> mkTwoColumn blksL blksR
((blksL1, blksL2), (blksR1, blksR2)) -> mkComparison blksL1 blksL2 blksR1 blksR2
let (blksL1, blksL2) = break notText blksL
(blksR1, blksR2) = break notText blksR
if (any null [blksL1, blksL2]) && (any null [blksR1, blksR2])
then mkTwoColumn blksL blksR
else mkComparison blksL1 blksL2 blksR1 blksR2
bodyBlocksToSlide _ (blk : blks) spkNotes = do
sldId <- asks envCurSlideId
inNoteSlide <- asks envInNoteSlide

View file

@ -103,8 +103,12 @@ tests = groupPptxTests [ pptxTests "Inline formatting"
"pptx/images/output.pptx"
, pptxTests "two-column layout"
def
"pptx/two-column/input.native"
"pptx/two-column/output.pptx"
"pptx/two-column/all-text/input.native"
"pptx/two-column/all-text/output.pptx"
, pptxTests "two-column (not comparison)"
def
"pptx/two-column/text-and-image/input.native"
"pptx/two-column/text-and-image/output.pptx"
, pptxTests "speaker notes"
def
"pptx/speaker-notes/input.native"

View file

@ -0,0 +1,12 @@
[Header 1 ("slide-1",[],[]) [Str "Slide",Space,Str "1"]
,Div ("",["columns"],[])
[Div ("",["column"],[])
[Para [Image ("",[],[]) [Str "an",Space,Str "image"] ("lalune.jpg","fig:")]]
,Div ("",["column"],[])
[Para [Str "This",Space,Str "should",Space,Str "use",Space,Str "Two",Space,Str "Content,",Space,Emph [Str "not"],Space,Str "Comparison!"]]]
,Header 1 ("slide-2",[],[]) [Str "Slide",Space,Str "2"]
,Div ("",["columns"],[])
[Div ("",["column"],[])
[Para [Str "This",Space,Str "should",Space,Str "also",Space,Str "use",Space,Str "Two",Space,Str "Content"]]
,Div ("",["column"],[])
[Para [Image ("",[],[]) [Str "an",Space,Str "image"] ("lalune.jpg","fig:")]]]]

Binary file not shown.

Binary file not shown.

Binary file not shown.