Commit Graph
2374 Commits
Author SHA1 Message Date
John MacFarlane 26b25a4428 LaTeX writer: new method for ensuring images don't overflow.
Previously we relied on graphicx internals and made global
changes to Gin to force images to be resized if they exceed
textwidth.  This approach is brittle and caused problems
with `\includesvg` (see #9660).

The new approach uses a new macro `\pandocbounded` that is
now defined in the LaTeX template. (Thanks here to Falk Hanisch in
https://github.com/mrpiggi/svg/issues/60.)

The LaTeX writer has been changed to enclose `\includegraphics`
and `\includesvg` commands in this macro when they don't explicitly
specify a width or height.

In addition, the writer now adds `keepaspectratio` to the
`\includegraphics` or `\includesvg` options if `height` is specified
without width, or vice versa. Previously, this was set in the preamble
as a global option.

Compatibility issues:

- If custom templates are used with the new LaTeX writer, they will have
  to be updated to include the new `\pandocbounded` macro, or an error
  will be raised because of the undefined macro.

- Documents that specify explicit dimensions for an image may render
  differently, if the dimensions are greater than the line width or
  page height. Previously pandoc would shrink these images to fit,
  but the new behavior takes the specified dimensions literally.
  In addition, pandoc previously always enforced `keepaspectratio`,
  even when width and height were both specified, so images with
  width and height specified that do not conform to their intrinsic
  aspect ratio will appear differently.

Closes #9660.
2024-06-23 16:12:37 -07:00
John MacFarlane 965de61edb Markdown writer: fix bug with block quotes in lists.
Closes #9908.
2024-06-23 14:33:58 -07:00
John MacFarlane b07c05a1e5 OpenXML writer: be craftier in adding East Asian font hints.
In some cases we need to break up a long text run including
both western and East Asian text, so that the punctuation in
the western text doesn't become double-wide.

Closes #9817.
2024-06-22 21:37:06 -07:00
John MacFarlane bee5b1fcd1 HTML writer: ensure URI escaping needed for html4.
Unicode characters need not be escaped for html5, and still won't be.

See #9905.
2024-06-22 18:48:55 -07:00
John MacFarlane 2b60b1a1bc RST reader: Support :cite: role with citeproc.
This patch supports a subset of the functionality of the
sphinxcontrib-bibtex extension to Sphinx. See
<https://sphinxcontrib-bibtex.readthedocs.io/en/latest/quickstart.html>.

Closes #9904.
2024-06-21 23:30:27 -07:00
John MacFarlane 7de74f3404 Add command test for #9358. 2024-06-21 11:15:04 -07:00
John MacFarlane 7786b72584 LaTeX reader: fix parsing of dimensions beginning with ..
E.g., `\kern.1pt`.

Closes #9902.
2024-06-21 11:14:31 -07:00
John MacFarlane 34aeb289c9 Textile reader: don't let spans begin right after a symbol.
Closes #9878.
2024-06-18 13:24:59 -07:00
John MacFarlane 532bbc875b Use latest commonmark-extensions.
This fixes `auto_identifiers` and `ascii_auto_identifiers`
extensions so that they substitute aliases for emojis,
as documented.

See #9876.
2024-06-17 19:57:33 -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 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 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
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 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 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
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 aeb84b5d13 Fix command test #6285 for Windows. 2024-06-01 16:21:39 -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 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 439e586bc7 Use dev version of djoths. 2024-05-31 09:38:34 -06:00
John MacFarlane 7abfec3d2c Fix typo in fix to template.typst. 2024-05-30 18:24:52 -06:00
John MacFarlane 0e92d9483c Typst template: use content rather than string...
...for title, author, date, email.

Fixes #9823 (escaped `\@` in rendered email).
Allows formatting in title, author, date, and email fields.
Since the PDF metadata requires a string, and typst only
converts the title to a string (not the authors), we use
a small function content-to-string to do this conversion.
Background: https://github.com/typst/typst/issues/2196
2024-05-30 12:00:48 -06:00
John MacFarlane 441ef31b9e Update context writer tests for template change. 2024-05-30 11:35:47 -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 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 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 9753f5c114 Update reference docx for docx test. 2024-05-19 19:37:30 -07:00
John MacFarlane 1b006989b3 Fix validation errors in docx golden test. 2024-05-19 19:26:06 -07:00
John MacFarlane f874997f18 Fix abstract-title in openxml template. 2024-05-19 19:20:08 -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 c26211b0c9 Cleaned up Abstract Title and Subtitle in default reference docx.
Center Subtitle, remove color.
2024-05-18 10:50:07 -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 0c5fd01cb8 Update texinfo test 2024-05-15 18:08:13 -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
Mickaël Canouil fef5f2d94c Add subtitle to Typst template (#9747) 2024-05-12 09:39:27 -07:00
Gokul Rajiv 74add4b126 RST reader: fix figclass and align annotations for figures (#9744)
Fixes #7473 

Previously, `figclass`es weren't being extracted correctly.

`figclass` and `align` annotations are now implemented following the rst docs: these options apply to the figure while other options are passed onto the underlying image.
2024-05-10 15:55:06 -07:00
John MacFarlane 5b9a8ea99c Typst writer: add blank line in definition lists with multiple definitions.
See discussion #9704.
2024-04-28 14:58:18 -04:00
guqicun e2f43baac1 Fix some typos (#9638)
Signed-off-by: guqicun <guqicun@outlook.com>
2024-04-26 10:13:37 +02:00
John MacFarlane 03630a2c6e Update copyright dates to 2024. 2024-04-25 18:16:49 -07:00
John MacFarlane 49df8131a5 Markdown writer: don't try to align columns in pipe tables...
...with lines greater than COLUMNS.

The alignment just reduces readibility when the lines soft wrap.
2024-04-25 14:26:17 -07:00