aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmily Bourke <undergroundquizscene@protonmail.com>2021-09-17 16:05:06 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2021-10-17 17:24:30 -0700
commit8af15ab345bb0790cc3442722673d9da9f23a79c (patch)
tree573a438aa9d684178aabc3666e755862cd031beb
parent3f489bcb5897898d453bef549d6eba5f5d2120bf (diff)
downloadpandoc-8af15ab345bb0790cc3442722673d9da9f23a79c.tar.gz
pptx: Fix list level numbering
In PowerPoint, the content of a top-level list is at the same level as the content of a top-level paragraph – the only difference is that a list style has been applied. At the moment, the pptx writer increments the paragraph level on each list, turning what should be top-level lists into second-level lists. This commit changes that logic, only incrementing the paragraph level on continuation paragraphs of lists. - Fixes https://github.com/jgm/pandoc/issues/4828 - Fixes https://github.com/jgm/pandoc/issues/4663
-rw-r--r--pandoc.cabal2
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint/Presentation.hs31
-rw-r--r--test/Tests/Writers/Powerpoint.hs4
-rw-r--r--test/pptx/code-custom/output.pptxbin29817 -> 29807 bytes
-rw-r--r--test/pptx/code-custom/templated.pptxbin42884 -> 42877 bytes
-rw-r--r--test/pptx/code/output.pptxbin29815 -> 29806 bytes
-rw-r--r--test/pptx/code/templated.pptxbin42882 -> 42876 bytes
-rw-r--r--test/pptx/incremental-lists/with-flag/output.pptxbin77169 -> 77136 bytes
-rw-r--r--test/pptx/incremental-lists/with-flag/templated.pptxbin90280 -> 90251 bytes
-rw-r--r--test/pptx/incremental-lists/without-flag/output.pptxbin75411 -> 75386 bytes
-rw-r--r--test/pptx/incremental-lists/without-flag/templated.pptxbin88518 -> 88495 bytes
-rw-r--r--test/pptx/list-level/input.native20
-rw-r--r--test/pptx/list-level/output.pptxbin0 -> 28635 bytes
-rw-r--r--test/pptx/list-level/templated.pptxbin0 -> 41701 bytes
-rw-r--r--test/pptx/lists/output.pptxbin28664 -> 28657 bytes
-rw-r--r--test/pptx/lists/templated.pptxbin41729 -> 41724 bytes
-rw-r--r--test/pptx/pauses/without-incremental/output.pptxbin0 -> 50083 bytes
-rw-r--r--test/pptx/pauses/without-incremental/templated.pptxbin0 -> 63157 bytes
-rw-r--r--test/pptx/slide-breaks-toc/output.pptxbin31129 -> 31123 bytes
-rw-r--r--test/pptx/slide-breaks-toc/templated.pptxbin44195 -> 44191 bytes
-rw-r--r--test/pptx/speaker-notes-afterseps/output.pptxbin51494 -> 51486 bytes
-rw-r--r--test/pptx/speaker-notes-afterseps/templated.pptxbin64558 -> 64552 bytes
-rw-r--r--test/pptx/start-numbering-at/output.pptxbin28626 -> 28620 bytes
-rw-r--r--test/pptx/start-numbering-at/templated.pptxbin41691 -> 41686 bytes
24 files changed, 43 insertions, 14 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index 615feaccb..ac6cb8121 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -429,6 +429,8 @@ extra-source-files:
test/pptx/inline-formatting/*.pptx
test/pptx/lists/input.native
test/pptx/lists/*.pptx
+ test/pptx/list-level/input.native
+ test/pptx/list-level/*.pptx
test/pptx/raw-ooxml/input.native
test/pptx/raw-ooxml/*.pptx
test/pptx/remove-empty-slides/input.native
diff --git a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
index fe34d24dc..2f94dcc17 100644
--- a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
@@ -500,27 +500,23 @@ blockToParagraphs (Header _ (ident, _, _) ils) = do
blockToParagraphs (BulletList blksLst) = do
pProps <- asks envParaProps
incremental <- listShouldBeIncremental
- let lvl = pPropLevel pProps
local (\env -> env{ envInList = True
- , envParaProps = pProps{ pPropLevel = lvl + 1
- , pPropBullet = Just Bullet
+ , envParaProps = pProps{ pPropBullet = Just Bullet
, pPropMarginLeft = Nothing
, pPropIndent = Nothing
, pPropIncremental = incremental
}}) $
- concatMapM multiParBullet blksLst
+ concatMapM multiParList blksLst
blockToParagraphs (OrderedList listAttr blksLst) = do
pProps <- asks envParaProps
incremental <- listShouldBeIncremental
- let lvl = pPropLevel pProps
local (\env -> env{ envInList = True
- , envParaProps = pProps{ pPropLevel = lvl + 1
- , pPropBullet = Just (AutoNumbering listAttr)
+ , envParaProps = pProps{ pPropBullet = Just (AutoNumbering listAttr)
, pPropMarginLeft = Nothing
, pPropIndent = Nothing
, pPropIncremental = incremental
}}) $
- concatMapM multiParBullet blksLst
+ concatMapM multiParList blksLst
blockToParagraphs (DefinitionList entries) = do
incremental <- listShouldBeIncremental
let go :: ([Inline], [[Block]]) -> Pres [Paragraph]
@@ -545,14 +541,21 @@ blockToParagraphs blk = do
addLogMessage $ BlockNotRendered blk
return []
--- Make sure the bullet env gets turned off after the first para.
-multiParBullet :: [Block] -> Pres [Paragraph]
-multiParBullet [] = return []
-multiParBullet (b:bs) = do
+-- | Make sure the bullet env gets turned off after the first paragraph, and
+-- indent any continuation paragraphs.
+multiParList :: [Block] -> Pres [Paragraph]
+multiParList [] = return []
+multiParList (b:bs) = do
pProps <- asks envParaProps
p <- blockToParagraphs b
- ps <- local (\env -> env{envParaProps = pProps{pPropBullet = Nothing}}) $
- concatMapM blockToParagraphs bs
+ let level = pPropLevel pProps
+ ps <- local (\env -> env
+ { envParaProps = pProps
+ { pPropBullet = Nothing
+ , pPropLevel = level + 1
+ }
+ })
+ $ concatMapM blockToParagraphs bs
return $ p ++ ps
cellToParagraphs :: Alignment -> SimpleCell -> Pres [Paragraph]
diff --git a/test/Tests/Writers/Powerpoint.hs b/test/Tests/Writers/Powerpoint.hs
index 84bdd7476..f3663efbb 100644
--- a/test/Tests/Writers/Powerpoint.hs
+++ b/test/Tests/Writers/Powerpoint.hs
@@ -66,6 +66,10 @@ tests = let
def
"pptx/start-numbering-at/input.native"
"pptx/start-numbering-at/output.pptx"
+ , pptxTests "List continuation paragraph indentation"
+ def
+ "pptx/list-level/input.native"
+ "pptx/list-level/output.pptx"
, pptxTests "tables"
def
"pptx/tables/input.native"
diff --git a/test/pptx/code-custom/output.pptx b/test/pptx/code-custom/output.pptx
index ded8f1125..6c7a1a9ab 100644
--- a/test/pptx/code-custom/output.pptx
+++ b/test/pptx/code-custom/output.pptx
Binary files differ
diff --git a/test/pptx/code-custom/templated.pptx b/test/pptx/code-custom/templated.pptx
index 8bb0df1ff..116865c1f 100644
--- a/test/pptx/code-custom/templated.pptx
+++ b/test/pptx/code-custom/templated.pptx
Binary files differ
diff --git a/test/pptx/code/output.pptx b/test/pptx/code/output.pptx
index e700bc268..8fd00ff74 100644
--- a/test/pptx/code/output.pptx
+++ b/test/pptx/code/output.pptx
Binary files differ
diff --git a/test/pptx/code/templated.pptx b/test/pptx/code/templated.pptx
index 44f34cd64..0d7db048f 100644
--- a/test/pptx/code/templated.pptx
+++ b/test/pptx/code/templated.pptx
Binary files differ
diff --git a/test/pptx/incremental-lists/with-flag/output.pptx b/test/pptx/incremental-lists/with-flag/output.pptx
index 1ca1dbf17..82f5f926f 100644
--- a/test/pptx/incremental-lists/with-flag/output.pptx
+++ b/test/pptx/incremental-lists/with-flag/output.pptx
Binary files differ
diff --git a/test/pptx/incremental-lists/with-flag/templated.pptx b/test/pptx/incremental-lists/with-flag/templated.pptx
index 4ddf6bb75..e8482b25f 100644
--- a/test/pptx/incremental-lists/with-flag/templated.pptx
+++ b/test/pptx/incremental-lists/with-flag/templated.pptx
Binary files differ
diff --git a/test/pptx/incremental-lists/without-flag/output.pptx b/test/pptx/incremental-lists/without-flag/output.pptx
index 6f7261ba3..62e66e1fe 100644
--- a/test/pptx/incremental-lists/without-flag/output.pptx
+++ b/test/pptx/incremental-lists/without-flag/output.pptx
Binary files differ
diff --git a/test/pptx/incremental-lists/without-flag/templated.pptx b/test/pptx/incremental-lists/without-flag/templated.pptx
index ca5c9fdab..ac7be9564 100644
--- a/test/pptx/incremental-lists/without-flag/templated.pptx
+++ b/test/pptx/incremental-lists/without-flag/templated.pptx
Binary files differ
diff --git a/test/pptx/list-level/input.native b/test/pptx/list-level/input.native
new file mode 100644
index 000000000..e0b36b8e5
--- /dev/null
+++ b/test/pptx/list-level/input.native
@@ -0,0 +1,20 @@
+[Header 1 ("slide",[],[]) [Str "Slide"]
+,BulletList
+ [[Para [Str "Top-level"]
+ ,Para [Str "With",Space,Str "continuation",Space,Str "paragraph"]]
+ ,[Para [Str "Then:"]
+ ,BulletList
+ [[Plain [Str "nested"]]
+ ,[Plain [Str "list"]]
+ ,[Plain [Str "items"]]]]]
+,Header 1 ("slide-1",[],[]) [Str "Slide"]
+,Para [Str "Paragraph."]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Top-level"]
+ ,Para [Str "Continuation"]
+ ,OrderedList (1,Decimal,Period)
+ [[Para [Str "Sub-list"]
+ ,Para [Str "With",Space,Str "Continuation"]]
+ ,[Para [Str "(still",Space,Str "sub-list)"]]]]
+ ,[Para [Str "(back",Space,Str "to",Space,Str "top-level)"]]]
+,Para [Str "Paragraph."]]
diff --git a/test/pptx/list-level/output.pptx b/test/pptx/list-level/output.pptx
new file mode 100644
index 000000000..5e3506958
--- /dev/null
+++ b/test/pptx/list-level/output.pptx
Binary files differ
diff --git a/test/pptx/list-level/templated.pptx b/test/pptx/list-level/templated.pptx
new file mode 100644
index 000000000..8853a3082
--- /dev/null
+++ b/test/pptx/list-level/templated.pptx
Binary files differ
diff --git a/test/pptx/lists/output.pptx b/test/pptx/lists/output.pptx
index 94a424f42..e23f47218 100644
--- a/test/pptx/lists/output.pptx
+++ b/test/pptx/lists/output.pptx
Binary files differ
diff --git a/test/pptx/lists/templated.pptx b/test/pptx/lists/templated.pptx
index 52097489f..290b5b519 100644
--- a/test/pptx/lists/templated.pptx
+++ b/test/pptx/lists/templated.pptx
Binary files differ
diff --git a/test/pptx/pauses/without-incremental/output.pptx b/test/pptx/pauses/without-incremental/output.pptx
new file mode 100644
index 000000000..9085db330
--- /dev/null
+++ b/test/pptx/pauses/without-incremental/output.pptx
Binary files differ
diff --git a/test/pptx/pauses/without-incremental/templated.pptx b/test/pptx/pauses/without-incremental/templated.pptx
new file mode 100644
index 000000000..6662e2451
--- /dev/null
+++ b/test/pptx/pauses/without-incremental/templated.pptx
Binary files differ
diff --git a/test/pptx/slide-breaks-toc/output.pptx b/test/pptx/slide-breaks-toc/output.pptx
index 788cdf148..f2660ef93 100644
--- a/test/pptx/slide-breaks-toc/output.pptx
+++ b/test/pptx/slide-breaks-toc/output.pptx
Binary files differ
diff --git a/test/pptx/slide-breaks-toc/templated.pptx b/test/pptx/slide-breaks-toc/templated.pptx
index d11744079..0a2bdb857 100644
--- a/test/pptx/slide-breaks-toc/templated.pptx
+++ b/test/pptx/slide-breaks-toc/templated.pptx
Binary files differ
diff --git a/test/pptx/speaker-notes-afterseps/output.pptx b/test/pptx/speaker-notes-afterseps/output.pptx
index 99110d3ca..b54ba4465 100644
--- a/test/pptx/speaker-notes-afterseps/output.pptx
+++ b/test/pptx/speaker-notes-afterseps/output.pptx
Binary files differ
diff --git a/test/pptx/speaker-notes-afterseps/templated.pptx b/test/pptx/speaker-notes-afterseps/templated.pptx
index daf8e2175..3b272ab1b 100644
--- a/test/pptx/speaker-notes-afterseps/templated.pptx
+++ b/test/pptx/speaker-notes-afterseps/templated.pptx
Binary files differ
diff --git a/test/pptx/start-numbering-at/output.pptx b/test/pptx/start-numbering-at/output.pptx
index bc74ec599..ecfc6901a 100644
--- a/test/pptx/start-numbering-at/output.pptx
+++ b/test/pptx/start-numbering-at/output.pptx
Binary files differ
diff --git a/test/pptx/start-numbering-at/templated.pptx b/test/pptx/start-numbering-at/templated.pptx
index 4f191a06e..f3f46ef30 100644
--- a/test/pptx/start-numbering-at/templated.pptx
+++ b/test/pptx/start-numbering-at/templated.pptx
Binary files differ