Commit Graph

52 Commits

Author SHA1 Message Date
John MacFarlane 8547196b44 Markdown reader: ordered sublists must start with 1
(or equivalent, e.g. 'i').  This brings the markdown
parser in line with commonmark, and avoids a lot of
unintended list starts.  Closes #11735.

Note that ordered lists that are not sublists may
still start with numbers other than 1.
2026-07-01 11:17:21 +02:00
John MacFarlane 3769d0cbf4 Typst template: fix regression introduced in 3.9.0.1.
This introduced a bug that will produce the error message
`the character `#` is not valid in code`.

Closes #11538.
2026-03-19 09:17:46 +01:00
John MacFarlane 4fbe52f4c1 Update typst tests for template change. 2026-03-17 11:00:39 +01:00
John MacFarlane bf45205b8a Update typst test for math changes. 2026-03-15 18:12:01 +01:00
Gordon Woodhull e427b7795e typst: use both place and block for title
otherwise the title will be confined to the left column
2026-02-16 23:36:50 +01:00
John MacFarlane cc72b8054c Typst writer: include alt attributes on images.
This borrows a test case taken mostly from #11394 by @mcanouil
but the code is fresh.  The behavior is similar to what we
have with the HTML and LaTeX writers.

Obsoletes #11394.

Co-authored by @mcanouil and Claude Opus 4.6.
2026-02-14 16:19:41 +01:00
John MacFarlane ebd425d867 Typst writer: don't add a carriage return after \ for hard break.
They are not necessary.  Note that they can still be included if
you use `--wrap=preserve` and add a newline in your source
document.

This fixes issues with line breaks in headings.
Closes #11446.
2026-02-07 10:57:50 +01:00
Mickaël Canouil 65f0b491c9 Typst template: improve accessibility of definition lists (#11436).
The show rule we used for definition lists created problems when
typst was run with `--pdf-standard=ua-1`.  This patch fixes things,
and also prevents definition list items from breaking across pages.
2026-02-03 21:58:28 +01:00
John MacFarlane 12ad483674 Typst template: disable hyphenation for title, subtitle.
Closes #11375.
2026-01-03 11:32:22 -05:00
John MacFarlane 379e389e20 Fix tests for #11259 change. 2025-10-30 17:46:15 +01:00
John MacFarlane 8b4e72e969 Typst template: fix font for compatibility with typst 0.14.
Typst 0.14 doesn't permit an empty array for `font`.
Closes #11238.
2025-10-26 19:43:03 +01:00
John MacFarlane 36cea7c978 Typst template: ensure that title block is properly centered.
Closes #11221.
2025-10-18 15:41:07 +02:00
John MacFarlane e87b86261f Typst writer: don't add semicolons as much.
Previously we added semicolons after inline commands not
followed by spaces, but mainly this was to deal with one issue:
the presence of a semicolon after an inline command, which
would be swallowed as a command separator (#9252).

This commits adopts an approach that should avoid so many
superfluous semicolons: it escapes semicolons that might come
right after a command.  See #11196.
2025-10-05 16:33:03 +02:00
John MacFarlane 9d452f801d Typst template: fix 3.8 regression in which links disappear.
A template change in 3.8 added a show rule for links which
causes them to disappear except in special cases.

This change fixes the problem.

Closes #11194.
2025-10-04 19:26:59 +02:00
Christopher T. Kenny 6070ad29cd Add features to typst base template (take 2).
New template variables supported: `thanks`, `abstract-title`, `linestretch`, `mathfont`, 
`codefont`, `linkcolor`, `filecolor`, `citecolor`.

Closes #9956, #11076.

(This is a new version of f000fa168b which
was reverted.)
2025-09-02 09:25:39 +02:00
John MacFarlane 4c69f288d9 Revert "Add features to typst base template."
This reverts commit f000fa168b.
2025-08-24 09:47:44 +02:00
Christopher Kenny f000fa168b Add features to typst base template.
This implements the changes suggested in #9956, with the exception of
the filecolor/urlcolor one. These would require adding some regex to
guess the link types. This is theoretically possible to do, but it
wasn't clear to me that this is a good thing to put in a default
template. Happy to adjust if you have thoughts on this.

Closes #9956.

Some things to note:

I'm converting colors by passing them as content, as I was seeing pandoc
escape # if that was included.

I set the default fonts for math and code ("raw") to fonts that are
bundled with Typst. These need not be those fonts if there are more
familiar pandoc preferences.
2025-07-24 10:45:28 -07:00
John MacFarlane e2a0cc9dda Use latest dev texmath. 2025-02-25 22:49:50 -08:00
John MacFarlane be734d2543 Remove definitions.typst partial.
Remove unnecessary definition of `endnote`.
Incorporate the one remaining definition into `default.typst`.
2024-11-11 10:23:18 -08:00
John MacFarlane d5d2821a4d Typst writer: make template sensitive to a page-numbering variable.
This can be set to an empty string (or, in metadata, to false) for
no page numbers.

Addresses #10370.
2024-11-09 11:38:08 -08:00
John MacFarlane 39b87d4d28 Adjust test suite for typst template changes.
Note: the new templates presuppose typst 0.12; if you try to
use an earlier version of typst, an error will be raised.
2024-10-29 14:49:06 -07:00
John MacFarlane bdb1172385 Typst writer: make smart extension work.
If `smart` is not enabled, a command in the default template will
disable smartquote substitutions.

When `smart` is enabled, render curly apostrophes as straight
and escape straight apostrophes.

When `smart` is disabled, render curly apostrophes as curly
and don't escape straight apostrophes.

And similarly for quotes, em and en dashes.

This should give more idiomatic typst output, with fewer unnecessary
escapes.

Closes #10271.
2024-10-08 21:58:25 -07:00
John MacFarlane a27dad6f68 Add options to change table/figure caption positions.
+ Add command line options `--table-caption-position` and
  `--figure-caption-position`. These allow the user to specify whether
  to put captions above or below tables and figures, respectively.
  The following output formats are supported: HTML (and related such
  as EPUB), LaTeX (and Beamer), Docx, ODT/OpenDocument, Typst.

+ Text.Pandoc.Options: add `CaptionPosition` and new
  `WriterOptions` fields `writerFigureCaptionPosition` and
  `writerTableCaptionPosition` [API change].

+ Text.Pandoc.Opt: add `Opt` fields `optFigureCaptionPosition` and
  `optTableCaptionPosition` [API change].

+ Docx writer: make table/figure rendering sensitive to caption
  position settings.

+ OpenDocument writer: make table/figure rendering sensitive to
  caption position settings.

+ Typst writer/template: implement figure caption positions by
  triggering a show rule in the default template, which determines caption
  positions for figures and tables globally.

+ LaTeX writer: make table/figure rendering sensitive to caption
  position settings. Closes #5116.

+ HTML writer/template: make `<figcaption>` placement sensitive to caption
  position settings.  For tables, `<caption>` must be the first element,
  and positioning is determined by CSS, for here we set a variable
  which the default template is sensitive to.
2024-09-08 08:29:09 -07: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
Mickaël Canouil fef5f2d94c Add subtitle to Typst template (#9747) 2024-05-12 09:39:27 -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
John MacFarlane 604f541b0f Typst writer: support Typst 0.11 table features. (#9593)
* Typst writer: support Typst 0.11 table features.

- colspans
- rowspans
- cell alignment overrides
- relative column widths
- header and footer
- multiple table bodies with intermediate headers

Row heads are not yet supported.

The default typst template has been modified so that tables
don't have lines by default. As is standard with pandoc, we only
add a line under a header or over a footer. However, a different
default stroke pattern can easily be added in a template.

Closes #9588.
2024-03-20 14:25:08 -07:00
John MacFarlane 660823e2ec Typst writer: only use explicit figure 'kind' for tables.
The rest of the time the autodetection should work fine.
2024-03-17 15:46:17 -07:00
John MacFarlane 2c5d66cb5c Typst writer: use kind: image for image figures. 2024-03-17 11:39:32 -07:00
John MacFarlane a6392207fc Typst writer: avoid unnecessary box around image in figure.
See #9236.
2024-03-17 11:29:25 -07:00
John MacFarlane 9ae7557ac0 Typst writer: omit width/height in images unless explicitly specified.
Previously we computed width/heigth for images that didn't have
size information, because otherwise typst would expand the image
to fit page width. This typst behavior has changed in 0.11.
This change fixes a bug in which images would sometimes overflow
page margins, depending on their intrinsic size.

Closes #9236.
2024-03-17 10:59:47 -07:00
John MacFarlane 2514ad2531 Typst template: set table inset globally. 2024-03-16 10:26:14 -07:00
John MacFarlane 876bd49786 Typst writer: add 'kind' parameter to figures.
This helps to distinguish tables from other figures for
purposes of labeling and numbering.

Closes #9574.
2024-03-14 10:16:51 -07:00
John MacFarlane b6ac32b116 Typst writer escaping improvements.
We no longer escape `(`. The reason we did this before (#9137)
has been addressed in another way (#9252).

We only escape `=`, `+`, `-` at the beginning of a line.

We now also escape `/` at the beginning of a line.

This should reduce unnecessary escapes.

Closes #9386.
2024-01-29 10:53:51 -08:00
John MacFarlane fd73880a87 Typst writer: emit ; after typst code...
unless followed by space.  Otherwise there's the potential
that the typst code will swallow up a following character.
Closes #9252.
2023-12-14 12:28:04 -08:00
John MacFarlane b46d00343a Depend on texmath 0.12.8.6.
This gives us less verbose typst math output.
2023-12-12 19:08:30 -08:00
John MacFarlane ea9317c73d Typst template fixes. 2023-12-11 10:18:37 -08:00
John MacFarlane aa95770743 Typst writer: use quote for block quotes.
Remove custom definitiion of blockquote in default template.
2023-12-09 23:23:15 -08:00
John MacFarlane e46c3e68d2 Update typst-hs commit and typst writer test. 2023-12-08 13:10:33 -08:00
John MacFarlane a67223c442 Typst writer: add #box around image to make it inline. (#9149)
An `#image` by itself in typst is a block-level element.
To force images to be inline (as they are in pandoc), we need
to add a box with an explicit width. When a width is not given
in image attributes, we compute one from the image itself, when
possible.

Closes #9104, supersedes #9105.
2023-10-20 12:18:46 -07:00
John MacFarlane 802c610923 Typst writer: escape (.
If it occurs in certain contexts, it can be parsed as function
application.  Simplest thing to do is to escape it always.
Closes #9137.
2023-10-16 22:39:48 -07:00
John MacFarlane 40accba747 Typst writer: use ~ for nonbreaking space.
And escape literal `~`.
Closes #9010.
2023-08-21 11:29:27 -07:00
John MacFarlane cc371a9485 Typst writer: put the label in right place for Div, use #block.
Closes #8991.

Previously we were putting the label at the beginning of
the Div's contents, but according to the documentation such a
label gets attached to the *preceding* element.  We now use an
explicit `#block` and add the label at the end.
2023-08-09 11:38:38 -07:00
John MacFarlane 284eb378e8 Typst writer: improve handling of autolinks.
Closes #8931.
2023-06-30 09:05:04 -07:00
John MacFarlane 2c8de4c129 Typst writer: use #footnote for notes.
Closes #8893.
2023-06-05 16:07:36 -07:00
John MacFarlane 826b8912ad Typst writer: use <..> for labels, create internal links.
Internal links to labels are now supported.
2023-04-05 12:57:25 -07:00
John MacFarlane ae8ba75c0a Typst writer: fix alignment issue in lists.
It's an aesthetic issue only; the first line had an
extra space indent after the list marker.
2023-03-27 18:52:57 -07:00
John MacFarlane fd85560b84 Typst: Use customized term instead of custom macro for def lists. 2023-03-27 10:47:15 -07:00
John MacFarlane 4780b4760d More Typst writer improvements.
+ Update manual with variables for Typst.
+ Split `lang` metadata into separate `lang` and `region` for Typst.
+ Fix label positioning in Divs.
+ Fix text customizations (lang, region, font, size) so they actually
  work.
+ Update tests and man page.
2023-03-26 21:32:31 -07:00