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
This commit is contained in:
parent
3f489bcb58
commit
8af15ab345
24 changed files with 43 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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"
|
||||
|
|
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.
20
test/pptx/list-level/input.native
Normal file
20
test/pptx/list-level/input.native
Normal file
|
@ -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."]]
|
BIN
test/pptx/list-level/output.pptx
Normal file
BIN
test/pptx/list-level/output.pptx
Normal file
Binary file not shown.
BIN
test/pptx/list-level/templated.pptx
Normal file
BIN
test/pptx/list-level/templated.pptx
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/pptx/pauses/without-incremental/output.pptx
Normal file
BIN
test/pptx/pauses/without-incremental/output.pptx
Normal file
Binary file not shown.
BIN
test/pptx/pauses/without-incremental/templated.pptx
Normal file
BIN
test/pptx/pauses/without-incremental/templated.pptx
Normal file
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.
Loading…
Reference in a new issue