8937 Commits
Author SHA1 Message Date
John MacFarlane 18931eda90 Add copyright info to two modules missing it. 2024-12-07 17:39:33 -08:00
John MacFarlane 567e6a15ac Stylistic tweak. 2024-12-07 11:42:34 -08:00
John MacFarlane 9013814c82 Ensure that --sandbox affects --embed-resources.
Previously it did not (contrary to what was implied by the manual),
which means that an image with URL `/etc/passwd` would leak an
encoded version of that file to HTML output with `--self-contained`
or `--embed-resources`, even if `--sandbox` was used.

Thanks to Samuel Mortenson for pointing out the issue.
2024-12-07 11:40:46 -08:00
John MacFarlane 8cf9da6b40 T.P.App.OutputSettings: add sandbox' function.
This computes the sandboxed files from Opt and avoids some
code repetition in T.P.App and T.P.App.OutputSettings.
2024-12-07 11:39:17 -08:00
John MacFarlane e70c2ac2ee Docx reader: handle \b, \i, \y modifiers in XE index entries.
See #10171.
2024-12-07 09:28:53 -08:00
John MacFarlane e9389ab4d5 HTML reader: parse footnotes defined by dpub-aria roles.
Closes #5294.
2024-12-07 08:57:35 -08:00
Evan Silberman 13b3453009 Add mdoc reader
This change introduces a reader for mdoc, a roff-derived semantic markup
language for manual pages. The two relevant contemporary implementations
of mdoc for manual pages are mandoc (https://mandoc.bsd.lv/), which
implements the language from scratch in C, and groff
(https://www.gnu.org/software/groff/), which implements it as roff macros.

mdoc has a lot of semantics specific to technical manuals that aren't
representable in Pandoc's AST. I've taken a cue from the mandoc HTML
output and many mdoc elements are encoded as Codes or Spans with classes
named for the mdoc macro that produced them.

Much like web browsers with HTML, mandoc attempts to produce best-effort
output given all kinds of weird and crappy mdoc input. Part of the
reason it's able to do this is it uses a very accommodating parse tree
and stateful output routines specialized to the output mode, and when it
encounters some macro it wasn't expecting, it can easily give up on
whatever it was outputting and output something else. I've encoded as
much flexibility as I reasonably could into the mdoc reader here, but I
don't know how to be as flexible as mandoc.

This branch has been developed almost exclusively against mandoc's
documentation and implementation of mdoc as a reference, and the
real-world manual pages tested against are those from the OpenBSD base
system. Of ~3500 manuals in mdoc format shipped with a fresh OpenBSD
install, 17 cause the mdoc reader to exit with a parse error. Any
further chasing of edge cases is deferred to future work.

Many of the tests in test/Tests/Readers/Mdoc.hs are derived directly
from mandoc's extensive regression tests.

[API change] Adds readMdoc to the public API
2024-12-05 22:57:18 -08:00
Evan Silberman 126e3330b9 Parameterize Roff escaping
The existing lexRoff does some stuff I don't want to deal with in mdoc
just yet, like lexing tbl, and some stuff I won't do at all, like
handling macro and text string definitions and switching between modes.
Uses a typeclass with associated type families to reuse most of the
escaping code between Roff (i.e. man) and Mdoc.

Future work could improve on this so that more lexing code could be
shared between Man and Mdoc. Mdoc inherits Roff's surface syntax so
hypothetically it makes sense to lex it into tokens that make sense for
roff. But it happens that the Mdoc parser is much easier to build with
an Mdoc specific token stream. Some discussion in jgm/pandoc#10225 about
the rationale.

Adds a test for the roff \A escape, which I accidentally dropped support
for in an earlier iteration without anything complaining.
2024-12-05 22:57:18 -08:00
John MacFarlane f87116a0b4 Docx reader: improve index reference support.
Support crossrefs.
Clean up and unify switch parsing for fields.
2024-12-05 11:37:09 -08:00
John MacFarlane d07ada43a0 Docx reader: parse index references as empty Spans.
See #10171.
2024-12-05 10:18:48 -08:00
silby 9f6f2c843d Fix comments in TEI writer referring to DocBook (#10430) 2024-12-01 22:09:12 -08:00
John MacFarlane 561e1de8cb Commonmark implicit_figures should check for empty caption...
...and not produce an implicit figure in this case.

Closes #10429.
2024-11-30 09:09:29 -07:00
John MacFarlane 5f4c4ae223 EPUB writer: use standardized filename for cover image...
...instead of the original name.

This avoids problems with e.g. filenames containing spaces.
Closes #10404.
2024-11-24 09:11:52 -08:00
John MacFarlane 7d2bd2c9a0 Markdown writer: issue INFO warning when not rendering table...
...e.g., when `raw_html` is disabled and the table can't be
fit into a supported markdown table format.

Closes #10407.
2024-11-23 10:21:27 -08:00
silby 1e928814bf Add WebP support to ImageSize (#10397)
Text.Pandoc.ImageSize: Add `Webp` constructor on ImageType.  [API change]
2024-11-22 09:26:29 -08:00
John MacFarlane fabfaabd81 MediaWiki reader: fix indented tables with caption.
Closes #10390.
2024-11-19 09:46:53 -08:00
Caleb Maclennan 1e917dd1fc Text.Pandoc.Format: remove duplicate typst entry (#10388) 2024-11-15 20:51:31 +01:00
Evan Silberman a4b8591150 Respect empty LineBlock lines in ANSI writer 2024-11-11 16:00:47 -08:00
Evan Silberman fdef25eb6e Respect empty LineBlock lines in plain writer
The plain writer behaved as a markdown variant with Ext_line_blocks
turned off, and so empty lines in a line block would get eliminated.
This is surprising, since if there's anything where the intent can be
preserved in plain text output it's empty lines.

It's still a bit surprising to have nbsps in plain text output, as in
the test, where the distinction doesn't really matter, but that'd be an
orthogonal change.
2024-11-11 16:00:47 -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 b088a55e56 Docx reader: handle case where Zotero itemData has different id...
from the citationItem id.  In this case we use the citationItemId
in the bibliography as well, overriding the referenceId in the itemData.

Closes #10366.
2024-11-08 09:28:49 -08:00
Andreas Deininger eeb8b1eb3a Fix typos (#10349) 2024-11-06 10:04:33 -08:00
Andreas Deininger 17634be3f4 JATS writer: correct spelling of suppress attribute (#10350) 2024-11-04 10:07:20 -08:00
John MacFarlane d87c7611f4 LaTeX writer: ensure that beamer footnotes go on frame, not column.
Closes #5769.
2024-10-28 09:53:31 -07:00
John MacFarlane d66f6e943b LaTeX reader: put minipage in specially marked Div.
Closes #10266.
2024-10-25 09:41:59 -07:00
John MacFarlane fc8f4534cf Typst reader: support underparen, overparen. 2024-10-23 21:52:03 -07:00
John MacFarlane c17c2040ed RST reader: support :file: on raw directive.
Closes #8584.
2024-10-23 20:44:09 -07:00
John MacFarlane cd5dab1874 RST reader: implement option lists.
Closes #10318.
2024-10-23 17:26:46 -07:00
Albert Krewinkel 4c66bf2790 HTML writer: unwrap empty incremental divs
Divs are unwrapped if the only purpose of the div seems to be to control
whether lists are presented incrementally on slides.

Closes: #10328
2024-10-23 09:04:54 -07:00
John MacFarlane 71d73f8da4 PDF via LaTeX: always do max runs if toc is present.
Closes #10308.

The old method (checking to see if toc hash had changed) is not
completely reliable; there are cases where an additional run is
needed anyway to get the correct "logical" page
numbers (especially when different pagination is used for
front matter). See #10308 for an example.
2024-10-22 09:12:12 -07:00
John MacFarlane 7330ad5a3c PDF: use .source extension, not .html, in toPdfViaTempFile.
See #10314.
2024-10-21 20:27:51 -07:00
John MacFarlane 430628ac0b Typst reader: avoid generating empty paragraphs. 2024-10-21 19:11:42 -07:00
John MacFarlane a67584adef Typst reader: fix #quote attribution.
If attribution is not present, don't print the `--`.

See #10320.
2024-10-21 18:52:50 -07:00
John MacFarlane 461f7607aa Typst reader: Fix typo in unicode code point for em dash.
This affects attributions in quote blocks.
See #10320.
2024-10-21 18:45:16 -07:00
John MacFarlane b21b7aeeb8 Issue warnings for duplicate YAML metadata keys.
Text.Pandoc.Logging: add YamlWarning constructor to LogMessage
[API change].

Closes #10312.
2024-10-21 11:16:21 -07:00
John MacFarlane 012d22cd11 RST reader: handle block level substitutions. 2024-10-16 23:49:54 -07:00
John MacFarlane 812b264a92 RST reader: avoid putting metadata in Para.
Create MetaInlines when possible, just as with markdown input.
MetaBlocks is still used when there are multiple paragraphs or
non-paragraph content.

This change also affects field lists.

Closes #7766.
2024-10-15 23:16:11 -07:00
John MacFarlane 019f5d1c9d RST reader: fix linked substitutions.
E.g. `|Python|_`.

Closes #6588.
2024-10-15 11:52:32 -07:00
John MacFarlane 300e18efba RST reader: support inline anchors.
Closes #9196.
2024-10-15 11:25:28 -07:00
John MacFarlane e9e1684c9e RST reader: explicit links define references.
For example, ``Go to `g`_ `g <www.example.com>`_.``
should produce two links to www.example.com.

Closes #5081.
2024-10-15 11:07:20 -07:00
John MacFarlane c8fda8f4d3 RST reader: Use a new one-pass parsing strategy.
Instead of having an initial pass where we collect reference
definitions, we create links with target `##SUBST##something`
or `##REF##something` or `##NOTE##something`, and resolve these
in a pass over the parsed AST.

This allows us to handle link references that are not at the
top level. Closes #10281.
2024-10-13 15:51:05 -06:00
John MacFarlane c5bab883ec RST reader: ignore newlines in URL in explicit link.
Closes #10279.
2024-10-09 08:54:27 -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 0b51580e2d MediaWiki reader: Fix parsing of col/rowspan.
Closes #6992.
2024-10-08 20:13:45 -07:00
John MacFarlane 70b2c5f3a9 T.P.SelfContained: improve handling of links to remote CSS.
Previously these were only converted to a `<style>` element
if the link was being served with a text/css mime type (not
e.g. text/plain).  We now add a secondary check for `rel="stylesheet"`
to better handle such cases.

Closes #10261.
2024-10-05 09:31:41 -07:00
John MacFarlane 93d745742d Docx reader: reset lists after headers in same list numId.
Headings in docx, even ones that do not have a visible number,
can have a numId, and in odd cases can even share a numId with
a list that continues after the header. In this case the list
numbering should be reset by the header.

To accomplish this, we add a Heading constructor to BodyPart and
include on it all the information list items have.

Closes #10258.
2024-10-03 22:21:59 -07:00
John MacFarlane 4211efaad1 Remove unnecessary import. 2024-10-01 11:04:31 -07:00
John MacFarlane 7048254397 Allow extracting data: URIs even in PandocPure (--sandbox).
These don't require IO, so we should allow it in sandboxed
mode.  Closes #10249.
2024-10-01 10:16:23 -07:00
John MacFarlane c3eec896ab Text.Pandoc.Class: export extractURIData.
[API change]
2024-10-01 10:15:50 -07:00
John MacFarlane 4f15b03ad2 RST writer: change bullet list hang from 3 to 2.
This accords with the style in the reference docs.
2024-10-01 09:19:53 -07:00