summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/Markdown.hs
AgeCommit message (Collapse)Author
2024-02-12Markdown writer: use different width fences for nested divs.John MacFarlane
Outer divs have longer fences. This aids clarity for the reader, making it easier to see where the div ends. It also makes the output compatible with some other implementations, e.g. micromark, which require different-width fences for nesting. Closes #9450.
2023-12-22Markdown writer: add table identifier at end of caption if present.John MacFarlane
Suggested at #9279.
2023-12-05Fine-tuning on alerts.John MacFarlane
Added a test to show that we can convert smoothly between gfm, rst, and asciidoc alerts.
2023-12-04Add `alerts` extension.John MacFarlane
This enables GitHub style markdown alerts as a commonmark extension. <https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts> This extension is now default for `gfm`. It can't be used with `markdown`, only with `commonmark` and variants.
2023-06-27Support --id-prefix for markdown output.John MacFarlane
Closes #8878.
2023-03-14Markdown writer: use implicit figures if there's a caption but no alt.Albert Krewinkel
Closes: #8689
2023-01-13Remove block constructor Null from the code base.John MacFarlane
It has been removed from pandoc-types.
2023-01-13Support complex figures. [API change]Albert Krewinkel
Thanks and credit go to Aner Lucero, who laid the groundwork for this feature in the 2021 GSoC project. He contributed many changes, including modifications to the readers for HTML, JATS, and LaTeX, and to the HTML and JATS writers. Shared (Albert Krewinkel): - The new function `figureDiv`, exported from `Text.Pandoc.Shared`, offers a standardized way to convert a figure into a Div element. Readers (Aner Lucero): - HTML reader: `<figure>` elements are parsed as figures, with the caption taken from the respective `<figcaption>` elements. - JATS reader: The `<fig>` and `<caption>` elements are parsed into figure elements, even if the contents is more complex. - LaTeX reader: support for figures with non-image contents and for subfigures. - Markdown reader: paragraphs containing just an image are treated as figures if the `implicit_figures` extension is enabled. The identifier is used as the figure's identifier and the image description is also used as figure caption; all other attributes are treated as belonging to the image. Writers (Aner Lucero, Albert Krewinkel): - DokuWiki, Haddock, Jira, Man, MediaWiki, Ms, Muse, PPTX, RTF, TEI, ZimWiki writers: Figures are rendered like Div elements. - Asciidoc writer: The figure contents is unwrapped; each image in the the figure becomes a separate figure. - Classic custom writers: Figures are passed to the global function `Figure(caption, contents, attr)`, where `caption` and `contents` are strings and `attr` is a table of key-value pairs. - ConTeXt writer: Figures are wrapped in a "placefigure" environment with `\startplacefigure`/`\endplacefigure`, adding the features caption and listing title as properties. Subfigures are place in a single row with the `\startfloatcombination` environment. - DocBook writer: Uses `mediaobject` elements, unless the figure contains subfigures or tables, in which case the figure content is unwrapped. - Docx writer: figures with multiple content blocks are rendered as tables with style `FigureTable`; like before, single-image figures are still output as paragraphs with style `Figure` or `Captioned Figure`, depending on whether a caption is attached. - DokuWiki writer: Caption and "alt-text" are no longer combined. The alt text of a figure will now be lost in the conversion. - FB2 writer: The figure caption is added as alt text to the images in the figure; pre-existing alt texts are kept. - ICML writer: Only single-image figures are supported. The contents of figures with additional elements gets unwrapped. - HTML writer: the alt text is no longer constructed from the caption, as was the case with implicit figures. This reduces duplication, but comes at the risk of images that are missing alt texts. Authors should take care to provide alt texts for all images. Some readers, most notably the Markdown reader with the `implicit_figures` extension, add a caption that's identical to the image description. The writer checks for this and adds an `aria-hidden` attribute to the `<figcaption>` element in that case. - JATS writer: The `<fig>` and `<caption>` elements are used write figures. - LaTeX writer: complex figures, e.g. with non-image contents and subfigures, are supported. The `subfigure` template variable is set if the document contains subfigures, triggering the conditional loading of the *subcaption* package. Contants of figures that contain tables are become unwrapped, as longtable environments are not allowed within figures. - Markdown writer: figures are output as implicit figures if possible, via HTML if the `raw_html` extension is enabled, and as Div elements otherwise. - OpenDocument writer: A separate paragraph is generated for each block element in a figure, each with style `FigureWithCaption`. Behavior for single-image figures therefore remains unchanged. - Org writer: Only the first element in a figure is given a caption; additional block elements in the figure are appended without any caption being added. - RST writer: Single-image figures are supported as before; the contents of more complex images become nested in a container of type `float`. - Texinfo writer: Figures are rendered as float with type `figure`. - Textile writer: Figures are rendered with the help of HTML elements. - XWiki: Figures are placed in a group. Co-authored-by: Aner Lucero <4rgento@gmail.com>
2023-01-10Update copyright years, it's 2023!Albert Krewinkel
2022-12-20Markdown writer: avoid HTML fallbacks in the generated TOC.Albert Krewinkel
The generated table of contents usually has IDs for each TOC link, allowing to link back to specific parts of the TOC. However, this leads to unidiomatic markup in formats like gfm, which do not support attributes on links and hence fall back to HTML. The IDs on TOC items are now removed in that case, leading to more aesthetic TOCs. Closes: #8131
2022-10-31Add explicit imports to fix compiler warnings.John MacFarlane
2022-10-31First stab at mtl 2.3 compliance.John MacFarlane
This will no doubt produce a bunch of warnings and hence CI failures, which we'll need to work around with explicit imports.
2022-10-19Text.Pandoc.Shared: remove `elemText`, `notElemText`. [API change]John MacFarlane
2022-10-16T.P.Parsing: Remove gratuitious renaming of Parsec types.John MacFarlane
We were exporting Parser, ParserT as synonyms of Parsec, ParsecT. There is no good reason for this and it can cause confusion. Also, when possible, we replace imports of Text.Parsec with T.P.Parsing. The idea is to make it easier, at some point, to switch to megaparsec or another parsing engine if we want to. T.P.Parsing new exports: Stream(..), updatePosString, SourceName, Parsec, ParsecT [API change]. Removed exports: Parser, ParserT [API change].
2022-09-19Commonmark writer: ensure that we don't have blank lines in raw HTML.John MacFarlane
Closes #8307.
2022-04-22Markdown writer: disable soft wrapping when `hard_line_breaks` enabled.John MacFarlane
We were already doing this for `markdown`; this commit does the same thing for `markua` and `commonmark` and `gfm`. Closes #8035.
2022-04-08Commonmark/markua/gfm writers: avoid excessive indentation...John MacFarlane
on bullet lists. They are now nested by 2 spaces instead of 4. See #8011.
2022-03-18Markdown writer: move table-related code into submodule.Albert Krewinkel
2022-02-26Markdown writer: don't produce redundant header identifier...John MacFarlane
when the `gfm_auto_identifiers` extension is set. Closes #7941.
2022-02-23Remove trailing whitespace in Writers.Markdown.Albert Krewinkel
2022-01-19Markdown writer: handle explicit column widths with pipe tables.John MacFarlane
If a table has explicit column width information *and* the content extends beyond the `--columns` width, we need to adjust the widths of the pipe separators to encode this width information. Closes #7847.
2022-01-17Fix some haddock errors.John MacFarlane
2022-01-03Markdown writer: fix indentation issue in footnotes.John MacFarlane
Closes #7801.
2022-01-02Copyright notices: update for 2022Albert Krewinkel
2021-12-19Add a writer for Markua 0.10 (#7729)binaarinen
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-05Commonmark writer: allow ')' delimiters on ordered lists.John MacFarlane
2021-11-04Allow `plain` to be used in raw attribute syntax.John MacFarlane
2021-10-27Markdown writer: Be sure to quote special values in YAML metadata.John MacFarlane
E.g. "Y", "yes", which are now (with yaml library) considered boolean values, as well as "null". This fixes a bug with roundtripping markdown -> markdown: ``` --- foo: "true" ... ```
2021-10-22Use simpleFigure in Readers.Aner Lucero
2021-10-12Revert "Depend on pandoc-types 1.23, remove Null constructor on Block."John MacFarlane
This reverts commit fb0d6c7cb63a791fa72becf21ed493282e65ea91.
2021-10-01Depend on pandoc-types 1.23, remove Null constructor on Block.John MacFarlane
2021-06-28Markdown writer: put space between Plain and following fenced Div.John MacFarlane
Closes #4465.
2021-06-21Markdown writer: Fix regression in code blocks with attributes.John MacFarlane
Code blocks with a single class but nonempty attributes were having attributes drop as a result of #7242. Closes #7397.
2021-06-12Markdown writer: allow `pipe_tables` to be disabled for commonmark...John MacFarlane
(commonmark_x, gfm). Closes #7375.
2021-06-05CommonMark writer: do not use simple class for fenced-divsJan Tojnar
In https://github.com/jgm/pandoc/pull/7242, we introduced a simple attribute style for for code blocks and fenced divs with a single class but turns out the CommonMark extension does not support it for fenced divs. https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md
2021-06-05CommonMark writer: do not throw away attributes when Ext_attributes is enabledJan Tojnar
Ext_attributes covers at least the following: - Ext_fenced_code_attributes - Ext_header_attributes - Ext_inline_code_attributes - Ext_link_attributes
2021-06-05Markdown writer: re-use functions from InlineJan Tojnar
Instead of duplicating linkAttributes and attrsToMarkdown, let’s just use those from the Inline module.
2021-04-25Markdown writer: Cleaner (code)blocks with single class (#7242)Jan Tojnar
When a block only has a single class and no other attributes, it is not necessary to wrap the class attribute in curly braces – the class name can be placed after the opening mark as is. This will result in bit cleaner output when pandoc is used as a markdown pretty-printer.
2021-04-25Add quotes properly in markdown YAML metadata fields.John MacFarlane
This fixes a bug, which caused the writer to look at the LAST rather than the FIRST character in determining whether quotes were needed. So we got spurious quotes in some cases and didn't get necessary quotes in others. Closes #7245. Updated a number of test cases accordingly.
2021-04-05Commonmark writer: Use backslash escapes for `<` and `|`...John MacFarlane
instead of entities. Closes #7208.
2021-03-19Protect partial uses of maximum with NonEmpty.John MacFarlane
2021-03-02Split up T.P.Writers.Markdown...John MacFarlane
with T.P.Writers.Markdown.Types and T.P.Writers.Markdown.Inline. The module was difficult to compile on low-memory system.s
2021-02-26Fix/update URLs and use HTTP**S** where possible (#7122)Salim B
2021-01-29Markdown writer: handle math right before digit.John MacFarlane
We insert an HTML comment to avoid a `$` right before a digit, which pandoc will not recognize as a math delimiter.
2021-01-12Markdown writer: cleaned up raw formats.John MacFarlane
We now react appropriately to gfm, commonmark, and commonmark_x as raw formats.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel
2021-01-07gfm/commonmark writer: implement start number on ordered lists.John MacFarlane
Previously they always started at 1, but according to the spec the start number is respected. Closes #7009.
2020-12-15Properly handle boolean values in writing YAML metadata.John MacFarlane
(Markdown writer.) This requires doctemplates >= 0.9. Closes #6388.
2020-12-04Markdown writer: ensure that a new csl-block begins on a new line.John MacFarlane
This just looks better and doesn't affect the semantics. See #6921.
2020-11-14Markdown writer: default to using ATX headings.Aner Lucero
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.