aboutsummaryrefslogtreecommitdiff
path: root/test/Tests/Writers
AgeCommit message (Collapse)AuthorFilesLines
2021-12-19Add a writer for Markua 0.10 (#7729)binaarinen1-0/+40
Markua is a markdown variant used by Leanpub. More information about Markua can be found at https://leanpub.com/markua/read. Adds a new exported function `writeMarkua` from T.P.Writers.Markdown. [API change] Closes #1871. Co-authored by Tim Wisotzki and Samuel Lemmenmeier.
2021-12-10Powerpoint tests: shorten lines by grouping testsAlbert Krewinkel1-189/+186
This makes the test output more pleasant to read in narrow terminal windows.
2021-11-12JATS writer: ensure figures are wrapped with `<p>` in list items.Albert Krewinkel1-15/+33
This prevents the generation of invalid output.
2021-10-17pptx: Fix list level numberingEmily Bourke1-0/+4
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
2021-10-14asciidoc writer: translate numberLines attribute to linesnum switchSamuel Tardieu1-0/+16
AsciiDoctor allows to request line numbering on code blocks by using a switch on the `source` block, such as in: ``` [source%linesnum,haskell] ---- some Haskell code here ---- ```
2021-10-07pptx: Remove excessive layout testsEmily Bourke1-20/+15
When I added the tests for moved layouts and deleted layouts, I added them to all tests. However, this doesn’t really give a lot more info than having single tests, and the extra tests take up time and disk space. This commit removes the moved-layouts and deleted-layouts tests, in favour of a single test for each of those scenarios.
2021-10-04OOXML tests: use pretty-printed form to display diffs.John MacFarlane1-3/+3
Otherwise everything is on one line and the diff is uninformative.
2021-10-02Fix compareXML helper in Tests.Writers.OOXML.John MacFarlane1-6/+6
Given how it is used, we were getting "mine" and "good" flipped in the test results.
2021-09-18pptx: Support footers in the reference docEmily Bourke1-184/+213
In PowerPoint, it’s possible to specify footers across all slides, containing a date (optionally automatically updated to today’s date), the slide number (optionally starting from a higher number than 1), and static text. There’s also an option to hide the footer on the title slide. Before this commit, none of that footer content was pulled through from the reference doc: this commit supports all the functionality listed above. There is one behaviour which may not be immediately obvious: if the reference doc specifies a fixed date (i.e. not automatically updating), and there’s a date specified in the metadata for the document, the footer date is replaced by the metadata date. - Include date, slide number, and static footer content from reference doc - Respect “slide number starts from” option - Respect “Don’t show on title slide” option - Add tests
2021-09-16pptx: Support specifying slide background imagesEmily Bourke1-0/+4
In the reveal-js output, it’s possible to use reveal’s `data-background-image` class on a slide’s title to specify a background image for the slide. With this commit, it’s possible to use `background-image` in the same way for pptx output. Only the “stretch” mode is supported, and the background image is centred around the slide in the image’s larger axis, matching the observed default behaviour of PowerPoint. - Support `background-image` per slide. - Add tests. - Update manual.
2021-09-15pptx: Add support for incremental listsEmily Bourke1-0/+8
- Support -i option - Support incremental/noincremental divs - Support older block quote syntax - Add tests One thing not clear from the manual is what should happen when the input uses a combination of these things. For example, what should the following produce? ```md ::: {.incremental .nonincremental} - are - these - incremental? ::: ::: incremental ::::: nonincremental - or - these? ::::: ::: ::: nonincremental > - how > - about > - these? ::: ``` In this commit I’ve taken the following approach, matching the observed behaviour for beamer and reveal.js output: - if a div with both classes, incremental wins - the innermost incremental/nonincremental div is the one which takes effect - a block quote containing a list as its first element inverts whether the list is incremental, whether or not the quote is inside an incremental/non-incremental div I’ve added some tests to verify this behaviour. This commit closes issue #5689 (https://github.com/jgm/pandoc/issues/5689).
2021-09-13pptx: Fix logic for choosing Comparison layoutEmily Bourke1-2/+6
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.
2021-09-10Support `--reference-location` for HTML output (#7461)Francesco Mazzoli1-1/+74
The HTML writer now supports `EndOfBlock`, `EndOfSection`, and `EndOfDocument` for reference locations. EPUB and HTML slide show formats are also affected by this change. This works similarly to the markdown writer, but with special care taken to skipping section divs with what regards to the block level. The change also takes care to not modify the output if `EndOfDocument` is used.
2021-09-01pptx: Add support for more layoutsEmily Bourke1-2/+59
Until now, the pptx writer only supported four slide layouts: “Title Slide” (used for the automatically generated metadata slide), “Section Header” (used for headings above the slide level), “Two Column” (used when there’s a columns div containing at least two column divs), and “Title and Content” (used for all other slides). This commit adds support for three more layouts: Comparison, Content with Caption, and Blank. - Support “Comparison” slide layout This layout is used when a slide contains at least two columns, at least one of which contains some text followed by some non-text (e.g. an image or table). The text in each column is inserted into the “body” placeholder for that column, and the non-text is inserted into the ObjType placeholder. Any extra content after the non-text is overlaid on top of the preceding content, rather than dropping it completely (as currently happens for the two-column layout). + Accept straightforward test changes Adding the new layout means the “-deleted-layouts” tests have an additional layout added to the master and master rels. + Add new tests for the comparison layout + Add new tests to pandoc.cabal - Support “Content with Caption” slide layout This layout is used when a slide’s body contains some text, followed by non-text (e.g. and image or a table). Before now, in this case the image or table would break onto a new slide: to get that output again, users can add a horizontal rule before the image or table. + Accept straightforward tests The “-deleted-layouts” tests all have an extra layout and relationship in the master for the Content with Caption layout. + Accept remove-empty-slides test Empty slides are still removed, but the Content with Caption layout is now used. + Change slide-level-0/h1-h2-with-text description This test now triggers the content with caption layout, giving a different (but still correct) result. + Add new tests for the new layout + Add new tests to the cabal file - Support “Blank” slide layout This layout is used when a slide contains only blank content (e.g. non-breaking spaces). No content is inserted into any placeholders in the layout. Fixes #5097. + Accept straightforward test changes Blank layout now copied over from reference doc as well, when layouts have been deleted. + Add some new tests A slide should use the blank layout if: - It contains only speaker notes - It contains only an empty heading with a body of nbsps - It contains only a heading containing only nbsps - Change ContentType -> Placeholder This type was starting to have a constructor for each placeholder on each slide (e.g. `ComparisonUpperLeftContent`). I’ve changed it instead to identify a placeholder by type and index, as I think that’s clearer and less redundant. - Describe layout-choosing logic in manual
2021-09-01pptx: Restructure testsEmily Bourke1-57/+57
- Use dashes consistently rather than underscores - Make a folder for each set of tests - List test files explicitly (Cabal doesn’t support ** until version 2.4)
2021-08-27pptx: Make first heading title if slide level is 0Emily Bourke1-0/+25
Before this commit, the pptx writer adds a slide break before any table, “columns” div, or paragraph starting with an image, unless the only thing before it on the same slide is a heading at the slide level. In that case, the item and heading are kept on the same slide, and the heading is used as the slide title (inserted into the layout’s “title” placeholder). However, if the slide level is set to 0 (as was recently enabled) this makes it impossible to have a slide with a title which contains any of those items in its body. This commit changes this behaviour: now if the slide level is 0, then items will be kept with a heading of any level, if the heading’s the only thing before the item on the same slide.
2021-08-17OOXML tests: silence warnings.John MacFarlane1-0/+1
These can make the test output confusing, making people think tests are failing when they're passing.
2021-08-17pptx: Select layouts from reference doc by nameEmily Bourke1-7/+24
Until now, users had to make sure that their reference doc contains layouts in a specific order: the first four layouts in the file had to have a specific structure, or else pandoc would error (or sometimes successfully produce a pptx file, which PowerPoint would then fail to open). This commit changes the layout selection to use the layout names rather than order: users must make sure their reference doc contains four layouts with specific names, and if a layout with the right name isn’t found pandoc will output a warning and use the corresponding layout from the default reference doc as a fallback. I believe the use of names rather than order will be clearer to users, and the clearer errors will help them troubleshoot when things go wrong. - Add tests for moved layouts - Add tests for deleted layouts - Add newly included layouts to slideMaster1.xml to fix tests
2021-08-17Don’t compare cdLine in OOXML golden testsEmily Bourke1-1/+0
The `cdLine` field gives the line of the file some CData was found on. I don’t think this is a difference that should fail these golden tests, as the XML should still be parsable if nothing else has changed.
2021-08-17Provide more detailed XML diff in testsEmily Bourke1-21/+51
I had some failing tests and couldn’t tell what was different in the XML. Updating the comparison to return what’s different made it easier to figure out what was wrong, and I think will be helpful for others in future.
2021-08-15Make docx writer sensitive to `native_numbering` extension.John MacFarlane1-1/+2
Figure and table numbers are now only included if `native_numbering` is enabled. (By default it is disabled.) This is a behavior change with respect to 2.14.1, but the behavior is that of previous versions. The change was necessary to avoid incompatibilities between pandoc's native numbering and third-party cross reference filters like pandoc-crossref. Closes #7499.
2021-06-29Docx writer: Add table numbering for captioned tables.John MacFarlane1-1/+3
The numbers are added using fields, so that Word can create a list of tables that will update automatically.
2021-06-05DocBook writer: Remove non-existent admonitionsJan Tojnar1-6/+6
attention, error and hint are actually just reStructuredText specific. danger was too until introduced in DocBook 5.2: https://github.com/docbook/docbook/issues/55
2021-05-28Docx reader: Read table column widths.Emily Bourke1-0/+5
2021-05-25Jira: add support for "smart" linksAlbert Krewinkel1-0/+8
Support has been added for the new `[alias|https://example.com|smart-card]` syntax.
2021-05-24Jira writer: use `{color}` when span has a color attributeAlbert Krewinkel1-0/+4
Closes: tarleb/jira-wiki-markup#10
2021-05-17HTML writer: ensure headings only have valid attribs in HTML4Albert Krewinkel1-52/+57
Fixes: #5944
2021-05-17ConTeXt writer: use span identifiers as reference anchors.Albert Krewinkel1-0/+3
Closes: #7246
2021-05-17ConTeXt writer tests: keep code lines below 80 chars.Albert Krewinkel1-113/+119
2021-04-28JATS writer: use either styled-content or named-content for spans.Albert Krewinkel1-5/+9
If the element has a content-type attribute, or at least one class, then that value is used as `content-type` and the span is put inside a `<named-content>` element. Otherwise a `<styled-content>` element is used instead. Closes: #7211
2021-04-10JATS writer: convert spans to <named-content> elementsAlbert Krewinkel1-0/+15
Spans with attributes are converted to `<named-content>` elements instead of being wrapped with `<milestone-start/>` and `<milestone-end>` elements. Milestone elements are not allowed in documents using the articleauthoring tag set, so this change ensures the creation of valid documents. Closes: #7211
2021-04-05JATS writer: escape disallows chars in identifiersAlbert Krewinkel1-90/+115
XML identifiers must start with an underscore or letter, and can contain only a limited set of punctuation characters. Any IDs not adhering to these rules are rewritten by writing the offending characters as Uxxxx, where `xxxx` is the character's hex code.
2021-03-20Include Header.Attr.attributes as XML attributes on sectionErik Rask1-0/+37
Add key-value pairs found in the attributes list of Header.Attr as XML attributes on the corresponding section element. Any key name not allowed as an XML attribute name is dropped, as are keys with invalid values where they are defined as enums in DocBook, and xml:id (for DocBook 5)/id (for DocBook 4) to not intervene with computed identifiers.
2021-03-13Jira writer: improve div/panel handlingAlbert Krewinkel1-0/+30
Include div attributes in panels, always render divs with class `panel` as panels, and avoid nesting of panels.
2021-03-08Jira writer: use noformat instead of code for unknown languages.Albert Krewinkel1-0/+10
Code blocks that are not marked as a language supported by Jira are rendered as preformatted text with `{noformat}` blocks. Fixes: tarleb/jira-wiki-markup#4
2021-03-01Jira writer: use Span identifiers as anchorsAlbert Krewinkel1-1/+8
Closes: tarleb/jira-wiki-markup#3.
2021-02-16Rename Text.Pandoc.XMLParser -> Text.Pandoc.XML.Light...John MacFarlane1-1/+2
..and add new definitions isomorphic to xml-light's, but with Text instead of String. This allows us to keep most of the code in existing readers that use xml-light, but avoid lots of unnecessary allocation. We also add versions of the functions from xml-light's Text.XML.Light.Output and Text.XML.Light.Proc that operate on our modified XML types, and functions that convert xml-light types to our types (since some of our dependencies, like texmath, use xml-light). Update golden tests for docx and pptx. OOXML test: Use `showContent` instead of `ppContent` in `displayDiff`. Docx: Do a manual traversal to unwrap sdt and smartTag. This is faster, and needed to pass the tests. Benchmarks: A = prior to 8ca191604dcd13af27c11d2da225da646ebce6fc (Feb 8) B = as of 8ca191604dcd13af27c11d2da225da646ebce6fc (Feb 8) C = this commit | Reader | A | B | C | | ------- | ----- | ------ | ----- | | docbook | 18 ms | 12 ms | 10 ms | | opml | 65 ms | 62 ms | 35 ms | | jats | 15 ms | 11 ms | 9 ms | | docx | 72 ms | 69 ms | 44 ms | | odt | 78 ms | 41 ms | 28 ms | | epub | 64 ms | 61 ms | 56 ms | | fb2 | 14 ms | 5 ms | 4 ms |
2021-02-13Org: support task_lists extensionAlbert Krewinkel1-11/+46
The tasks lists extension is now supported by the org reader and writer; the extension is turned on by default. Closes: #6336
2021-02-07Avoid unnecessary use of NoImplicitPrelude pragma (#7089)Albert Krewinkel19-36/+0
2020-12-13Docx writer: keep raw openxml strings verbatim.Albert Krewinkel1-0/+10
Closes: #6933
2020-12-07Docbook writer: Handle admonition titles from Markdown readerJan Tojnar1-0/+14
Docbook reader produces a `Div` with `title` class for `<title>` element within an “admonition” element. Markdown writer then turns this into a fenced div with `title` class attribute. Since fenced divs are block elements, their content is recognized as a paragraph by the Markdown reader. This is an issue for Docbook writer because it would produce an invalid DocBook document from such AST – the `<title>` element can only contain “inline” elements. Let’s handle this invalid special case separately by unwrapping the paragraph before creating the `<title>` element.
2020-12-07Docbook writer: handle admonitionsJan Tojnar1-0/+52
Similarly to https://github.com/jgm/pandoc/commit/d6fdfe6f2bba2a8ed25d6c9f11861774001f7a91, we should handle admonitions.
2020-11-14Markdown writer: default to using ATX headings.Aner Lucero1-1/+3
Previously we used Setext (underlined) headings by default. The default is now ATX (`##` style). * Add the `--markdown-headings=atx|setext` option. * Deprecate `--atx-headers`. * Add constructor 'ATXHeadingInLHS` constructor to `LogMessage` [API change]. * Support `markdown-headings` in defaults files. * Document new options in MANUAL. Closes #6662.
2020-10-06DOCX reader: Allow empty dates in comments and tracked changes (#6726)Diego Balseiro1-0/+5
For security reasons, some legal firms delete the date from comments and tracked changes. * Make date optional (Maybe) in tracked changes and comments datatypes * Add tests
2020-10-02Docx writer: better handle list items whose contents are lists (#6522)Michael Hoffmann1-0/+5
If the first element of a bulleted or ordered list is another list, then that first item will disappear if the target format is docx. This changes the docx writer so that it prepends an empty string for those cases. With this, no items will disappear. Closes #5948.
2020-09-13Fix hlint suggestions, update hlint.yaml (#6680)Christian Despres1-1/+1
* Fix hlint suggestions, update hlint.yaml Most suggestions were redundant brackets. Some required LambdaCase. The .hlint.yaml file had a small typo, and didn't ignore camelCase suggestions in certain modules.
2020-09-12[API change] Rename Writers.Tables and its contents (#6679)Christian Despres1-64/+66
Writers.Tables is now Writers.AnnotatedTable. All of the types and functions in it have had the "Ann" removed from them. Now it is expected that the module be imported qualified.
2020-09-05Add Writers.Tables helper functions and types, add tests for those (#6655)Christian Despres1-0/+252
Add Writers.Tables helper functions and types, add tests for those The Writers.Tables module contains an AnnTable type that is a pandoc Table with added inferred information that should be enough for writers (in particular the HTML writer) to operate on without having to lay out the table themselves. The toAnnTable and fromAnnTable functions in that module convert between AnnTable and Table. In addition to producing an AnnTable with coherent and well-formed annotations, the toAnnTable function also normalizes its input Table like the table builder does. Various tests ensure that toAnnTable normalizes tables exactly like the table builder, and that its annotations are coherent.
2020-07-08Escape starting periods in ms writer code blocksMichael Hoffmann1-0/+37
If a line of ms code block output starts with a period (.), it should be prepended by '\&' so that it is not interpreted as a roff command. Fixes #6505
2020-06-22Use native Underline instead of Span in JiraJohn MacFarlane1-2/+1