summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/HTML.hs
AgeCommit message (Collapse)Author
2024-02-12HTML5 writer: Add suffix to multiple footnote section idsSam May
The first (and often only) `<aside id=footnotes>` block remains unchanged, however any additional blocks from `--reference-location` are distinguished as `#footnotes-2`, `#footnotes-3`, and so on. No other existing writer seems to implement per-section IDs, including HTML4.
2024-02-03Shared: `makeSections` behavior changes.John MacFarlane
+ When the optional base level parameter is provided, we no longer ensure that the sequence of heading levels is gapless [behavior change]. Instead, we set the lowest heading level to the specified base level, and adjust the others accordingly. If an author wants to skip a level, e.g. from level 1 to level 3, they can do that. In general, the heading levels specified in the source document are preserved; `makeSections` only puts them into a hierarchical structure. Closes #9398. + Section numbers are now assigned so that the top level gets `1`, no matter what heading level is used. So, even if the top heading level is 2, numbers will be `1`, `2`, etc. rather than `0.1`, `0.2`, as in the past. Closes #5071. + We revert to the old behavior when the `--number-offset` option is used. So, for example, if a document begins with a level-3 heading, and `--number-offset=1,2` is used, the top-level section numbers will be `1.2.1`, `1.2.2`, etc. This is mainly for backwards-compatibility.
2024-01-27EPUB writer: add ARA roles for accessibility (#9378)Iacobus1983
This commit adds roles to some html element within epub in order to comply with accessibility best practices. Footnote references are given role "doc-noteref",footnote text gets "doc-footnote", and nav gets "doc-toc".
2024-01-20HTML writer: ensure that an alt attribute is added in EPUB output.John MacFarlane
This seems to be required by iBooks; even an empty alt attribute will satisfy it. Closes #9354.
2023-12-04HTML5 writer footnote changes (aria-role, element type).John MacFarlane
* To conform to validator's expectations, `doc-footnote` role is used with `aside` and `doc-endnotes` with `section`. * `aside` is used only for notes at ends of sections or blocks; if all the notes come at the end of the document, `section` is used so we can have the `doc-endnotes` role.
2023-10-27Fix spacing.John MacFarlane
2023-09-29Check if supplied FORMAT matches with an HTML slide deck value. Return True ↵James J Balamuta
for isRawHtml.
2023-09-07HTML writer: Fix CSL entry-spacing default.John MacFarlane
See #9058.
2023-09-01HTML writer: use the ID prefix in the ID for the footnotes section.Benjamin Esham
In general, the ID prefix makes it possible to combine multiple pieces of Pandoc-generated HTML with no possibility that IDs will conflict. One exception to this was that the footnotes were always put into an element like <aside id="foonotes" ...> This commit applies the ID prefix to this ID as well.
2023-07-12HTML writer: don't make line blocks sensitive to `--wrap`.John MacFarlane
Closes #8952.
2023-03-29HTML writer: use first paragraph in task item as checkbox label.Albert Krewinkel
Closes: #8729
2023-03-29Revert "HTML writer: wrap task items in labels."Albert Krewinkel
This reverts commit b208eb2a560b8571af577667d5df8706f4ba8892.
2023-03-29HTML writer: wrap task items in labels.Albert Krewinkel
The `<label>` element ensures that the item description is associated with the checkbox, which is important for accessibility. See: #8729
2023-03-20HTML writer: Remove redundant `nubOrd`.John MacFarlane
Now that we're doing `nubOrd` on classes at the end (when changing pandoc attributes to HTML attributes), we don't need to do it here.
2023-03-20Remove superfluous import.John MacFarlane
2023-03-20HTML writer: avoid duplicate classes.John MacFarlane
Closes #8705.
2023-03-15HTML writer: use img element instead of embed for .svg.gz...John MacFarlane
and .png.gz etc. Closes #8699.
2023-03-14HTML writer footnotes changes:John MacFarlane
When `--reference-location=section` or `=block`, use an `aside` element for the notes rather than a `section`. When `--reference-location=section`, include the `aside` element inside the section element, rather than outside. (In slide shows, this option causes footnotes on a slide to be displayed at the bottom of the slide.) Closes #8695.
2023-03-14Remove confusing comment.John MacFarlane
2023-03-08HTML writer: Use different structure for epub footnotes. (#8676)John MacFarlane
Many EPUB readers are thrown off by pandoc's current footnote output. Both the ol and the fact that the footnote backlink is at the end of the note seem to pose problems. With this commit, we now create a list of aside (or div) elements, instead of an ordered list. Each element begins with a note number that is linked back to the note reference. (So, the backlink occurs at the beginning rather than the end.) References: - https://kindlegen.s3.amazonaws.com/AmazonKindlePublishingGuidelines.pdf - http://kb.daisy.org/publishing/docs/html/notes.html See #8672, closes #5583. Thanks to @Porges and @lewer.
2023-01-21T.P.Writers.Shared: export setupTranslations [API change].John MacFarlane
Use this in HTML and OpenDocument writers.
2023-01-20HTML writer: don't omit newlines in task lists.John MacFarlane
2023-01-20HTML writer: don't disable checkboxes in task lists.John MacFarlane
Closes #8562.
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-04HTML writer: remove obsolete stuff about mathml-script.John MacFarlane
This was a shim we used to include for mathml support. We don't do anything with this any more, so this is dead code.
2022-12-04HTML writer: include math links if there are raw...John MacFarlane
commands or environments that can be interpreted as math e.g. by MathJax. See #8469.
2022-11-29HTML writer: Add prooftree to list of math environments.John MacFarlane
This will cause raw LaTeX prooftree environments to be rendered appropriately when `--mathjax` is used. Closes #8462.
2022-11-11[API change] Add functions htmlAddStyle, htmlAlignmentToString and htmlAttrs ↵Wout Gevaert
to Writers/Shared.hs The functions htmlAddStyle and htmlAlignmentToString are moved from Writers/HTML.hs, where they were called 'addStyle' and 'alignmentToString' respectively. The function htmlAttrs is split off from tagWithAttrs in Writers/Shared.hs. It creates a representation of an Attr object, as one would see in a tagWithAttrs (but without the tag)
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 `ordNub` [API change].John MacFarlane
This is just `nubOrd` from Data.Containers.ListUtils.
2022-10-15Minor code cleanups.John MacFarlane
2022-10-09HTML writer; Properly merge classes for headings of level > 6.John MacFarlane
Previously we got two separate `class` attributes in the `p` tag. Closes #8363.
2022-10-05HTML writer: replace deprecated aria roles for bibliography entries.John MacFarlane
`doc-biblioentry` -> `listitem` `doc-bibliography` -> `list` Closes #8354.
2022-10-03Rename T.P.Network.HTTP -> T.P.URI.John MacFarlane
This is still an unexported internal module. Export `urlEncode`, `escapeURI`, `isURI`, `schemes`, `uriPathToPath`. Re-export `escapeURI` and `isURI` from T.P.Shared (as they were exported before); drop exports of `schemes` and `uriPathToPath` [API change]. With this change, T.P.Class no longer depends on T.P.Shared.
2022-10-03Separate out T.P.Data, T.P.Translations from T.P.Class. (#8348)John MacFarlane
This makes T.P.Class more self-contained, and suitable for extraction into a separate package if desired. [API changes] - T.P.Data is now an exported module, providing `readDataFile`, `readDefaultDataFile` (both formerly provided by T.P.Class), and also `getDataFileNames` (formerly unexported in T.P.App.CommandLineOptions). - T.P.Translations is now an exported module (along with T.P.Translations.Types), providing `readTranslations`, `getTranslations`, `setTranslations`, `translateTerm`, `lookupTerm`, `readTranslations`, `Term(..)`, and `Translations`. - T.P.Class: `readDataFile`, `readDefaultDataFile`, `setTranslations`, and `translateTerm` are no longer exported. `checkUserDataDir` is now exported. - Text.Pandoc now exports Text.Pandoc.Data and `setTranslations` and `translateTerm`.
2022-09-28HTML writer: prevent `<a>` inside `<a>`.John MacFarlane
If a link text contains a link, we replace it with a span. See #7585.
2022-09-05HTML writer: only treat `. . .` as a slide pause in slides...John MacFarlane
...and not in regular HTML output. Closes #8281.
2022-08-27HTML, Markdown writers: filter out empty class attributes.John MacFarlane
These should not be generated by any pandoc readers, but they might be produced programatically. Technically that's a misuse of the AST, but since the expectation that the classes are nonempty strigs is not encoded in the types, it can happen. This patch limits the damage if it does, preventing invalid markdown attributes like `{.}` from being written. Cloess #8251.
2022-08-27Fix a small space leak in HTML writer.John MacFarlane
2022-08-26HTML writer: avoid aria-hidden in code blocks for HTML4.John MacFarlane
Closes #8241. This requires depending on a new (still unreleased) version of skylighting-format-blaze-html.
2022-08-25HTML writer: use role combinator from blaze....John MacFarlane
instead of customAttribute.
2022-08-25HTML writer: only add role attribute in HTML5.John MacFarlane
It is not valid in HTML4. See #8241.
2022-08-22HTML writer: revert to using `width` property for column widthsAlbert Krewinkel
The default `flex` and `overflow-x` properties of a column are set to `auto`. In combination, these changes allow to get good results when using columns with or without explicit widths.
2022-08-18HTML writer: use `flex` property for column widthsAlbert Krewinkel
Fixes: #8232
2022-07-25HTML writer: Allow "spanlike" classes to be combined.John MacFarlane
Previously classes like "underline" and "marked" had to be the first class in a span in order for the span to be interpreted as a "ul" or "mark" element. This commit allows these special classes to be "stacked," e.g. `[test]{.mark .underline}`; in addition, the special classes are no longer required to come first in the list of classes. See #8194 for context.
2022-06-23Remove extra soft break for tasklist (#8142)black-desk
Browser will display the extra newline character between checkbox and text as a space, which make tasklist items cannot be aligned. I just remove it.
2022-06-02HTML writer: fix bug with `--number-offset`.John MacFarlane
This formerly caused section divs to be produced, even when `--section-divs` was not specified. Closes #8097.
2022-04-28HTML writer: avoid doubled style attribute...John MacFarlane
when height and width are added to style because of an image, but the image already has a style attribute. Closes #8047.