From 4a7dad18b109987cfa13168a9f5505c183744d99 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Tue, 27 Aug 2019 01:16:21 -0400 Subject: PowerPoint writer: Start numbering at appopriate numbers. Starting numbers for ordered lists were previously ignored. Now we specify the number if it is something other than 1. Closes: #5709 --- src/Text/Pandoc/Writers/Powerpoint/Output.hs | 12 ++++++++---- test/Tests/Writers/Powerpoint.hs | 4 ++++ test/pptx/start_numbering_at.native | 9 +++++++++ test/pptx/start_numbering_at.pptx | Bin 0 -> 27031 bytes test/pptx/start_numbering_at_templated.pptx | Bin 0 -> 394323 bytes 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 test/pptx/start_numbering_at.native create mode 100644 test/pptx/start_numbering_at.pptx create mode 100644 test/pptx/start_numbering_at_templated.pptx diff --git a/src/Text/Pandoc/Writers/Powerpoint/Output.hs b/src/Text/Pandoc/Writers/Powerpoint/Output.hs index eed35565e..79a5ed65f 100644 --- a/src/Text/Pandoc/Writers/Powerpoint/Output.hs +++ b/src/Text/Pandoc/Writers/Powerpoint/Output.hs @@ -861,7 +861,7 @@ paragraphToElement par = do (case pPropBullet $ paraProps par of Just Bullet -> [] Just (AutoNumbering attrs') -> - [mknode "a:buAutoNum" [("type", autoNumberingToType attrs')] ()] + [mknode "a:buAutoNum" (autoNumAttrs attrs') ()] Nothing -> [mknode "a:buNone" [] ()] ) paras <- concat <$> mapM paraElemToElements (paraElems par) @@ -1872,10 +1872,14 @@ getContentType fp Just $ presML ++ ".slideLayout+xml" | otherwise = Nothing -autoNumberingToType :: ListAttributes -> String -autoNumberingToType (_, numStyle, numDelim) = - typeString ++ delimString +autoNumAttrs :: ListAttributes -> [(String, String)] +autoNumAttrs (startNum, numStyle, numDelim) = + numAttr ++ typeAttr where + numAttr = if startNum == 1 + then [] + else [("startAt", show startNum)] + typeAttr = [("type", typeString ++ delimString)] typeString = case numStyle of Decimal -> "arabic" UpperAlpha -> "alphaUc" diff --git a/test/Tests/Writers/Powerpoint.hs b/test/Tests/Writers/Powerpoint.hs index c21ee49a4..e3f4173bd 100644 --- a/test/Tests/Writers/Powerpoint.hs +++ b/test/Tests/Writers/Powerpoint.hs @@ -59,6 +59,10 @@ tests = groupPptxTests [ pptxTests "Inline formatting" def "pptx/lists.native" "pptx/lists.pptx" + , pptxTests "start ordered list at specified num" + def + "pptx/start_numbering_at.native" + "pptx/start_numbering_at.pptx" , pptxTests "tables" def "pptx/tables.native" diff --git a/test/pptx/start_numbering_at.native b/test/pptx/start_numbering_at.native new file mode 100644 index 000000000..ecffbb0ef --- /dev/null +++ b/test/pptx/start_numbering_at.native @@ -0,0 +1,9 @@ +[Header 2 ("example-numbering-mwe",[],[]) [Str "Example",Space,Str "numbering",Space,Str "MWE"] +,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "slide",Space,Str "with",Space,Str "examples",Space,Str "in",Space,Str "(1)",Space,Str "and",Space,Str "(2)"] +,OrderedList (1,Example,TwoParens) + [[Plain [Str "First"]] + ,[Plain [Str "Second"]]] +,Header 2 ("a-second-slide",[],[]) [Str "A",Space,Str "second",Space,Str "slide"] +,Para [Str "This",Space,Str "second",Space,Str "slide",Space,Str "has",Space,Str "a",Space,Str "third",Space,Str "example",Space,Str "in",Space,Str "(3)."] +,OrderedList (3,Example,TwoParens) + [[Plain [Str "Third"]]]] diff --git a/test/pptx/start_numbering_at.pptx b/test/pptx/start_numbering_at.pptx new file mode 100644 index 000000000..18477380b Binary files /dev/null and b/test/pptx/start_numbering_at.pptx differ diff --git a/test/pptx/start_numbering_at_templated.pptx b/test/pptx/start_numbering_at_templated.pptx new file mode 100644 index 000000000..4b9d0ba4d Binary files /dev/null and b/test/pptx/start_numbering_at_templated.pptx differ -- cgit v1.2.3