Commit Graph
8791 Commits
Author SHA1 Message Date
John MacFarlane 97b3056f4e Make gfm_auto_identifiers work as advertised.
It is supposed to replace emojis with their aliases,
but previously this only worked when the emojis were
in a specially marked span.

Note that this change doesn't affect `commonmark` (or `gfm`)
because the relevant code is in commonmark-hs. This will also
need updating.

See #9876.
2024-06-17 13:41:31 -07:00
John MacFarlane fde7908091 Markdown writer: don't print extra caption when using implicit_figures. 2024-06-12 23:00:58 -07:00
John MacFarlane 94975a4e3c Docx reader: improve handling of captions.
- Turn captioned images into Figure elements. Closes #9391.
- Improve the logic for associating elements with captions.
  Closes #9358.
- Ensure that captions that can't be associated with an
  element aren't just silently dropped. Closes #9610.
2024-06-12 22:31:33 -07:00
John MacFarlane b2f0d8e799 Docx reader: rename TblCaption to Capt.
We'll use this for image captions as well. Word does not really
distinguish these.
2024-06-12 10:27:32 -07:00
John MacFarlane 7e89a47f2e T.P.ImageSize: don't prefer exif width/height when they conflict...
...with width/height.  That was a mistaken call in #6936.
Usually when these values disagree, it is because the image
has been resized by a tool that leaves the original exif values
the same, so the width/height metadata are more likely to be
correct that exif width/height.

Closes #9871.
2024-06-11 16:44:23 -07:00
John MacFarlane cd9753d4af LaTeX writer/template: specify language option for selnolig...
...and only include it if `english` or `german` is used.

Since 3d8f011, the babel language is not specified as a
class option any more; so now we need to explicitly specify
the language option when we load `selnolig`.  Only `german`
and `english` are valid, so we construct the variable
`selnolig-langs` in the writer and include `selnolig` if it
is nonempty.

This should restore proper ligature suppression when
lualatex is used.

Closes #9863. Supersedes #9864.

Thanks to @fkohrt for the initial fix.
2024-06-10 19:33:43 -07:00
John MacFarlane c9a3f5466e SelfContained: strip CRs from XML before base64 encoding for data uri.
This is motivated mainly by the desire to get tests to work on Windows.
2024-06-10 12:48:35 -07:00
John MacFarlane f2092f82ff SelfContained: only create svg elements for SVG images when...
...the image has the class `inline-svg`. Otherwise just use a
`data` URI as we do with other images.

Closes #9787.
2024-06-10 10:59:16 -07:00
Albert Krewinkel 11a2f78cda PandocMonad: convert IOErrors to warnings when fetching absolute paths (#9859) 2024-06-08 08:40:42 -07:00
Albert Krewinkel 6f98149516 Fix "unused variable" warning. 2024-06-08 14:39:57 +02:00
John MacFarlane a0ba712b70 Textile writer: get rid of header, odd, even classes on tr.
This follows #9376.
2024-06-07 14:22:50 -07:00
John MacFarlane b4b0a6d61b Fixes to #9376. 2024-06-07 14:16:38 -07:00
ThomasSoeiro cd15313216 Don't emit unnecessary classes in HTML tables (#9376)
Pandoc used to emit a `header` class on the `tr` element that forms the table header. This is no longer needed, because `head > tr` will do the same thing.

Similarly, pandoc used to emit `even` and `odd` classes on `tr`s, allowing striped styling.  This is no longer needed, because one can use e.g. `tbody tr:nth-child(2n)`.

We now omit these classes, which have a good chance of conflicting with classes used for other things.

Closes #9325.
2024-06-07 12:15:40 -07:00
John MacFarlane 3d6a4d870a Fix warning. 2024-06-04 17:16:38 -07:00
John MacFarlane 0698eb4a8b LaTeX writer: task lists must be unordered.
Closes #9185.
2024-06-04 17:11:03 -07:00
John MacFarlane 3952d4d1a2 Docx reader: support task lists.
This also fixes a small bug in parsing delimiters in numbered lists,
which led to the default delimiter being used wrongly in some cases.

Closes #8211.
2024-06-04 15:17:43 -07:00
John MacFarlane e71f171fe2 T.P.Writers.Shared: export toTaskListItem instead of isTaskList.
This is more useful.  Use this in OpenXML and HTML writers.
2024-06-04 11:45:04 -07:00
John MacFarlane 75afa7829b T.P.Readers.Docx.Lists: replace a generic traversal...
using `bottomUp` with a faster one using `walk`.
2024-06-04 10:22:38 -07:00
John MacFarlane f5531f18a5 Docx writer: better formatting for task lists.
Task lists are now properly formatted, with no bullet.

In addition, we have removed an expensive generic traverse to
remove Space elements, and replaced it with code in
`inlinesToOpenXML`.  This should give better performance; it
also reduces XML size in the metadata, which wasn't previously
affected by the de-Spacing.

TODO: parse this in the reader so that we can have task lists round-trip.

Closes #5198.
2024-06-04 10:03:26 -07:00
John MacFarlane c4f530fac8 T.P.Writers.Shared: export isTaskList.
[API change]

This function used to be in T.P.Writers.HTML.
2024-06-04 09:12:36 -07:00
Carlos Scheidegger 347985fb83 typst,table - support '.typst:no-figure' and 'typst:figure:kind=kind' (#9778)
This extends support for fine-grained properties in Typst.

If the `typst:no-figure` class is present on a Table, the table will not be placed in a figure.

If the `typst:figure:kind` attribute is present, its value will be used for the figure's `kind`.

These features are documented in `doc/typst-property-output.md`.

Closes #9777.
2024-06-03 09:52:53 -07:00
John MacFarlane 39c549caad Docx writer: omit jc attribute on table cells with AlignDefault.
Closes #5662.
2024-06-01 22:31:03 -07:00
John MacFarlane 1992913ba5 Docx reader: react to "left" value on jc attribute.
Also fix tests.
2024-06-01 21:02:11 -07:00
John MacFarlane 3dfac974d0 Docx reader: handle column and cell alignments.
OpenXML doesn't have a way of indicating column alignments, but
we guess them by looking at the justification property on the
first paragraph of a cell, if there is one.

We take the column alignments from the first body row.

Closes #8551.
2024-06-01 20:01:48 -07:00
John MacFarlane 9a7fd6e7bf Docx reader: allow insertion/deletion to contain arbitrary ParParts...
...and not just Runs.  This fixes a problem wherein comments
inside insertions or deletions would be ignored. Closes #9833.
2024-06-01 17:34:36 -07:00
John MacFarlane 075ed1052f Support HorizontalRule in docx reader.
We support both pandoc-style and the style described at
https://support.microsoft.com/en-us/office/insert-a-horizontal-line-9bf172f6-5908-4791-9bb9-2c952197b1a9

Closes #6285.
2024-06-01 11:00:37 -07:00
John MacFarlane f7fcb5c470 T.P.Readers.Docx.Parse: add HRule constructor to BodyPart.
This paves the way to supporting horizontal rules in the reader.
We still need to adjust the parser to create HRule appropriately;
so far, this change has no effect, but it's a step on the way
to #6285.
2024-06-01 10:14:46 -07:00
John MacFarlane 7e7735bb6b Use \linewidth instead of \columnwidth or \textwidth...
for resizing figures, table cells, etc. in LaTeX.  `\linewidth`,
unlike the others, is sensitive to indented environments like
lists.

Closes #9775.
2024-05-31 15:03:06 -06:00
John MacFarlane 872d7bcd28 Fix metadata in docx writer.
The new OpenXML template had spaces for metadata that need
to be filled with OpenXML fragments with the proper shape.
This patch ensures that everything is the right shape.

Closes #9828.
2024-05-31 10:43:24 -06:00
John MacFarlane c19b44b071 Docx writer: wrap figures with id in a bookmark.
Closes #8862.
2024-05-29 16:08:24 -06:00
John MacFarlane a6c3945000 Docx writer: add eastAsia font hints to w:r.
We do this when the text in the run contains any CJK characters.
This ensures that ambiguous code points (e.g. quotation marks)
will be represented as "wide" characters when together with CJK
characters.

Closes #9817.
2024-05-29 15:38:34 -06:00
John MacFarlane 2f1f066759 Add unexported module Text.Pandoc.Char.
This exports `isCJK`.  Use this instead of locally defined
`isCJK` in T.P.Readers.MediaWiki.
2024-05-29 15:03:16 -06:00
John MacFarlane 29fa97ab96 HTML reader: better handle non-li elements in ul and ol.
For example, a `p` after a closed `li` will be incorporated into
the previous `li`. This mirrors what browsers do with this
invalid HTML.

Closes #9809.
2024-05-28 08:44:46 -07:00
John MacFarlane 372cd1d3b1 Typst reader: handle inline bodies ending in a parbreak.
E.g. `#strong[
test
]`.  Here we simply skip the final parbreak.

Treat this as a soft break, which will give results similar
to the typst app.
2024-05-27 19:46:08 -07:00
John MacFarlane 2e1f17a09f Typst reader: fix an incomplete pattern match.
See #9807.
2024-05-27 14:53:22 -07:00
John MacFarlane fa01764a0e CSV reader: turn line breaks into LineBreaks not SoftBreaks.
Closes #9797.
2024-05-27 14:32:59 -07:00
John MacFarlane 205e54c245 RST reader: tighten up rules fro when emphasis can start.
Closes #9805.
2024-05-27 14:11:43 -07:00
John MacFarlane a7c6a290dc Markdown writer: ensure blank line after HTML blocks...
in commonmark-based formats. Closes #9792.
2024-05-27 13:37:59 -07:00
John MacFarlane db559e100c Allow OpenXML templates to be used with docx.
The `--reference-doc` option allows customization of styles in docx
output, but it does not allow one to adjust the content of the output
(e.g., changing the order in which metadata, the table of contents,
and the body of the document are displayed), or adding boilerplate
text before or after the document body.  For these changes, one can
now use `--template` with an OpenXML template.  (See the default
`openxml` template for a sample.)

This patch also allows `--include-before-body` and
`--include-after-body` to be used with `docx` output.
The included files must be OpenXML fragments suitable for
inclusion in the document body.

Closes #8338 (`--include-before-body`, `--include-after-body`).

Closes #9069 (a custom template can be used to omit the
title page).

Closes #7256.

Closes #2928.
2024-05-19 13:09:21 -07:00
John MacFarlane e8f44a8543 Tweak imports to fix ghc 9.4 build failure. 2024-05-18 23:45:45 -07:00
John MacFarlane f73c610ae0 Factor out T.P.Writers.Docx.OpenXML (internal module). 2024-05-18 21:10:22 -07:00
John MacFarlane 2d74c75666 Allow author-only textual citations.
E.g. `-@reese2002` outside of brackets.

Closes #7219.
2024-05-18 10:26:27 -07:00
John MacFarlane d0b8237c3d Texinfo writer: improve menus.
Properly handle the case where the node name is different from
the descriptive title.
2024-05-15 17:08:42 -07:00
John MacFarlane a898be8b78 Texinfo writer: avoid duplicate node names. 2024-05-15 16:45:26 -07:00
John MacFarlane 133c59151c Texinfo writer: don't add anchors to headings.
We don't need them, now that we make internal links use the node.
2024-05-15 15:16:35 -07:00
John MacFarlane d12ab5fc55 Texinfo writer: Ensure proper escaping in all node/link contexts. 2024-05-15 12:45:33 -07:00
John MacFarlane aabca2eb6a Texinfo writer: target node rather than anchor when possible...
in internal links.
2024-05-15 12:15:50 -07:00
John MacFarlane 74f533396a Texinfo writer improvements.
- Remove illegal characters from internal link anchors (closes #6177).
- Use two commas not one in @ref.
2024-05-15 09:46:06 -07:00
John MacFarlane adcc8b2c96 Revert "texinfo writer: use node names for @ref when possible."
This reverts commit 33142af323.
2024-05-15 09:19:46 -07:00
John MacFarlane 33142af323 texinfo writer: use node names for @ref when possible.
References to an anchor don't seem to work when viewing
info files generated from the texi.  So we create a table
of node names corresponding to identifiers, and use these
when possible for internal links.
2024-05-14 22:03:10 -07:00