2017-12-28 10:39:47 -05:00
|
|
|
module Tests.Writers.Powerpoint (tests) where
|
|
|
|
|
2018-01-25 15:27:54 -05:00
|
|
|
import Tests.Writers.OOXML (ooxmlTest)
|
2017-12-28 10:39:47 -05:00
|
|
|
import Text.Pandoc
|
|
|
|
import Test.Tasty
|
2018-02-19 20:04:39 -05:00
|
|
|
import System.FilePath
|
2019-10-08 09:22:46 -07:00
|
|
|
import Text.DocTemplates (ToContext(toVal), Context(..))
|
|
|
|
import qualified Data.Map as M
|
|
|
|
import Data.Text (pack)
|
2021-08-10 17:20:53 +01:00
|
|
|
import Data.List (unzip4)
|
2018-02-19 20:04:39 -05:00
|
|
|
|
|
|
|
-- templating is important enough, and can break enough things, that
|
|
|
|
-- we want to run all our tests with both default formatting and a
|
|
|
|
-- template.
|
|
|
|
|
2021-08-10 17:20:53 +01:00
|
|
|
modifyPptxName :: FilePath -> String -> FilePath
|
|
|
|
modifyPptxName fp suffix =
|
2021-08-25 14:35:19 +01:00
|
|
|
addExtension (takeDirectory fp ++ suffix) "pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
|
2021-08-10 17:20:53 +01:00
|
|
|
pptxTests :: String -> WriterOptions -> FilePath -> FilePath -> (TestTree, TestTree, TestTree, TestTree)
|
2018-02-19 20:04:39 -05:00
|
|
|
pptxTests name opts native pptx =
|
2021-08-25 14:35:19 +01:00
|
|
|
let referenceDoc = "pptx/reference-depth.pptx"
|
|
|
|
movedLayoutsReferenceDoc = "pptx/reference-moved-layouts.pptx"
|
|
|
|
deletedLayoutsReferenceDoc = "pptx/reference-deleted-layouts.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
in
|
|
|
|
( ooxmlTest
|
|
|
|
writePowerpoint
|
|
|
|
name
|
|
|
|
opts{writerReferenceDoc=Nothing}
|
|
|
|
native
|
|
|
|
pptx
|
|
|
|
, ooxmlTest
|
|
|
|
writePowerpoint
|
|
|
|
name
|
|
|
|
opts{writerReferenceDoc=Just referenceDoc}
|
|
|
|
native
|
2021-08-25 14:35:19 +01:00
|
|
|
(modifyPptxName pptx "/templated")
|
2021-08-10 17:20:53 +01:00
|
|
|
, ooxmlTest
|
|
|
|
writePowerpoint
|
|
|
|
name
|
|
|
|
opts{writerReferenceDoc=Just movedLayoutsReferenceDoc}
|
|
|
|
native
|
2021-08-25 14:35:19 +01:00
|
|
|
(modifyPptxName pptx "/moved-layouts")
|
2021-08-10 17:20:53 +01:00
|
|
|
, ooxmlTest
|
|
|
|
writePowerpoint
|
|
|
|
name
|
|
|
|
opts{writerReferenceDoc=Just deletedLayoutsReferenceDoc}
|
|
|
|
native
|
2021-08-25 14:35:19 +01:00
|
|
|
(modifyPptxName pptx "/deleted-layouts")
|
2018-02-19 20:04:39 -05:00
|
|
|
)
|
|
|
|
|
2021-08-10 17:20:53 +01:00
|
|
|
groupPptxTests :: [(TestTree, TestTree, TestTree, TestTree)] -> [TestTree]
|
2018-02-19 20:04:39 -05:00
|
|
|
groupPptxTests pairs =
|
2021-08-10 17:20:53 +01:00
|
|
|
let (noRefs, refs, movedLayouts, deletedLayouts) = unzip4 pairs
|
2018-02-19 20:04:39 -05:00
|
|
|
in
|
|
|
|
[ testGroup "Default slide formatting" noRefs
|
|
|
|
, testGroup "With `--reference-doc` pptx file" refs
|
2021-08-10 17:20:53 +01:00
|
|
|
, testGroup "With layouts in reference doc moved" movedLayouts
|
|
|
|
, testGroup "With layouts in reference doc deleted" deletedLayouts
|
2018-02-19 20:04:39 -05:00
|
|
|
]
|
2018-01-22 09:02:20 -05:00
|
|
|
|
2017-12-28 10:39:47 -05:00
|
|
|
|
|
|
|
tests :: [TestTree]
|
2018-02-19 20:04:39 -05:00
|
|
|
tests = groupPptxTests [ pptxTests "Inline formatting"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/inline-formatting/input.native"
|
|
|
|
"pptx/inline-formatting/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
, pptxTests "Slide breaks (default slide-level)"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/slide-breaks/input.native"
|
|
|
|
"pptx/slide-breaks/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
, pptxTests "slide breaks (slide-level set to 1)"
|
|
|
|
def{ writerSlideLevel = Just 1 }
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/slide-breaks/input.native"
|
|
|
|
"pptx/slide-breaks-slide-level-1/output.pptx"
|
2018-02-27 09:34:24 -05:00
|
|
|
, pptxTests "lists"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/lists/input.native"
|
|
|
|
"pptx/lists/output.pptx"
|
2019-08-27 01:16:21 -04:00
|
|
|
, pptxTests "start ordered list at specified num"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/start-numbering-at/input.native"
|
|
|
|
"pptx/start-numbering-at/output.pptx"
|
2018-02-27 09:34:24 -05:00
|
|
|
, pptxTests "tables"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/tables/input.native"
|
|
|
|
"pptx/tables/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
, pptxTests "table of contents"
|
|
|
|
def{ writerTableOfContents = True }
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/slide-breaks/input.native"
|
|
|
|
"pptx/slide-breaks-toc/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
, pptxTests "end notes"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/endnotes/input.native"
|
|
|
|
"pptx/endnotes/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
, pptxTests "end notes, with table of contents"
|
|
|
|
def { writerTableOfContents = True }
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/endnotes/input.native"
|
|
|
|
"pptx/endnotes-toc/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
, pptxTests "images"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/images/input.native"
|
|
|
|
"pptx/images/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
, pptxTests "two-column layout"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/two-column/input.native"
|
|
|
|
"pptx/two-column/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
, pptxTests "speaker notes"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/speaker-notes/input.native"
|
|
|
|
"pptx/speaker-notes/output.pptx"
|
2018-03-21 10:05:05 -04:00
|
|
|
, pptxTests "speaker notes after a separating block"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/speaker-notes-afterseps/input.native"
|
|
|
|
"pptx/speaker-notes-afterseps/output.pptx"
|
2019-03-30 22:52:31 -04:00
|
|
|
, pptxTests "speaker notes after a separating header"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/speaker-notes-afterheader/input.native"
|
|
|
|
"pptx/speaker-notes-afterheader/output.pptx"
|
2019-03-31 17:05:45 -04:00
|
|
|
, pptxTests "speaker notes after metadata"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/speaker-notes-after-metadata/input.native"
|
|
|
|
"pptx/speaker-notes-after-metadata/output.pptx"
|
2018-02-27 09:09:45 -05:00
|
|
|
, pptxTests "remove empty slides"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/remove-empty-slides/input.native"
|
|
|
|
"pptx/remove-empty-slides/output.pptx"
|
2018-10-20 09:00:23 -04:00
|
|
|
, pptxTests "raw ooxml"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/raw-ooxml/input.native"
|
|
|
|
"pptx/raw-ooxml/output.pptx"
|
Improve writing metadata for docx, pptx and odt (#5252)
* docx writer: support custom properties. Solves the writer part of #3024.
Also supports additional core properties: `subject`, `lang`, `category`,
`description`.
* odt writer: improve standard properties, including the following core properties:
`generator` (Pandoc/VERSION), `description`, `subject`, `keywords`,
`initial-creator` (from authors), `creation-date` (actual creation date).
Also fix date.
* pptx writer: support custom properties. Also supports additional core
properties: `subject`, `category`, `description`.
* Includes golden tests.
* MANUAL: document metadata support for docx, odt, pptx writers
2019-01-26 16:14:35 -08:00
|
|
|
, pptxTests "metadata, custom properties"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/document-properties/input.native"
|
|
|
|
"pptx/document-properties/output.pptx"
|
Improve writing metadata for docx, pptx and odt (#5252)
* docx writer: support custom properties. Solves the writer part of #3024.
Also supports additional core properties: `subject`, `lang`, `category`,
`description`.
* odt writer: improve standard properties, including the following core properties:
`generator` (Pandoc/VERSION), `description`, `subject`, `keywords`,
`initial-creator` (from authors), `creation-date` (actual creation date).
Also fix date.
* pptx writer: support custom properties. Also supports additional core
properties: `subject`, `category`, `description`.
* Includes golden tests.
* MANUAL: document metadata support for docx, odt, pptx writers
2019-01-26 16:14:35 -08:00
|
|
|
, pptxTests "metadata, short description"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/document-properties-short-desc/input.native"
|
|
|
|
"pptx/document-properties-short-desc/output.pptx"
|
2019-06-14 17:42:06 +02:00
|
|
|
, pptxTests "inline code and code blocks"
|
|
|
|
def
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/code/input.native"
|
|
|
|
"pptx/code/output.pptx"
|
2019-06-14 17:42:06 +02:00
|
|
|
, pptxTests "inline code and code blocks, custom formatting"
|
2019-10-08 09:22:46 -07:00
|
|
|
def { writerVariables = Context $ M.fromList
|
|
|
|
[(pack "monofont", toVal $ pack "Consolas")] }
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/code/input.native"
|
|
|
|
"pptx/code-custom/output.pptx"
|
2021-08-20 14:40:09 +01:00
|
|
|
, pptxTests ("Using slide level 0, if the first thing on "
|
|
|
|
<> "a slide is a h1 it's used as the "
|
|
|
|
<> "slide title")
|
|
|
|
def { writerSlideLevel = Just 0 }
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/slide-level-0/h1-with-image/input.native"
|
|
|
|
"pptx/slide-level-0/h1-with-image/output.pptx"
|
2021-08-20 14:40:09 +01:00
|
|
|
, pptxTests ("Using slide level 0, if the first thing on "
|
|
|
|
<> "a slide is a h2 it's used as the "
|
|
|
|
<> "slide title")
|
|
|
|
def { writerSlideLevel = Just 0 }
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/slide-level-0/h2-with-image/input.native"
|
|
|
|
"pptx/slide-level-0/h2-with-image/output.pptx"
|
2021-08-20 14:40:09 +01:00
|
|
|
, pptxTests ("Using slide level 0, if the first thing on "
|
|
|
|
<> "a slide is a heading it's used as the "
|
|
|
|
<> "slide title (works with a table)")
|
|
|
|
def { writerSlideLevel = Just 0 }
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/slide-level-0/h1-with-table/input.native"
|
|
|
|
"pptx/slide-level-0/h1-with-table/output.pptx"
|
2021-08-20 14:40:09 +01:00
|
|
|
, pptxTests ("Using slide level 0, if the first thing on "
|
|
|
|
<> "a slide is a heading it's used as the "
|
|
|
|
<> "slide title (two headings forces a "
|
|
|
|
<> "slide break though)")
|
|
|
|
def { writerSlideLevel = Just 0 }
|
2021-08-25 14:35:19 +01:00
|
|
|
"pptx/slide-level-0/h1-h2-with-table/input.native"
|
|
|
|
"pptx/slide-level-0/h1-h2-with-table/output.pptx"
|
2018-02-19 20:04:39 -05:00
|
|
|
]
|