Commit Graph

2766 Commits

Author SHA1 Message Date
John MacFarlane 098c48d79f RTF reader: fix tables parsed as deeply nested tables.
Closes #11682.

Fixes two bugs that caused a simple table to be read as a cascade of
nested tables:

* `\plain` reset the entire property record (including the in-table
  flag) via `const def`.  When a cell paragraph used `\plain` after
  `\intbl`, the in-table flag was cleared, so the next `\cell` closed
  the partially-built table and embedded it inside a new cell.  Per the
  RTF spec, `\plain` should reset only character formatting, so it now
  preserves paragraph/context properties (in-table, list level, outline
  level, hyperlink, anchor).

* `\row` was ignored and only `\trowd` started a new row.  Real-world
  RTF often emits a single `\trowd` and separates rows with `\row`, so
  every cell ended up in one row.  Both `\trowd` and `\row` now begin a
  fresh row (only when the current one has cells), and empty trailing
  rows are dropped when closing the table.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-03 16:36:29 +02:00
John MacFarlane 676ccdc904 T.P.Writers.Shared: htmlAttrs: use data- prefix when needed.
This now behaves like the HTML writer, adding the `data-`
prefix for custom attributes.  This will affect, e.g.,
the mediawiki writer.

Closes #11680.
2026-06-03 12:23:44 +02:00
Meher Chaitanya 1ffeb856ee Add auto_identifiers support to Man Reader (#11675)
Add support for the `auto_identifiers`, `gfm_auto_identifiers`, and
`ascii_identifiers` extensions in the man reader. Section headings
parsed from .SH and .SS macros now receive auto-generated id
attributes when the extension is enabled, enabling `--toc` to
produce working anchor links.

- Add `autoIdExtensions` to default man extensions [behavior change]
- Add `HasReaderOptions`, `HasLogMessages` and `HasIdentifierList` to
  `ManState` to run `registerHeader`

Closes #8852.
2026-05-30 19:11:14 +02:00
Johan Larsson 41f829c43d Markdown reader: allow grid tables to be indented. (#11671)
Like the other table syntaxes (pipe, simple, and multiline tables) and
block-level constructs generally, a grid table may now be indented by up
to three spaces and still be recognized as a table.  Previously the
grid-table parser required the table to begin at the left margin, so an
indented grid table was parsed as a paragraph.

The leading indentation is stripped uniformly from each line before the
table is parsed, so an indented grid table produces the same AST as its
non-indented equivalent.

Adds a command test.
2026-05-28 00:07:29 +02:00
John MacFarlane 1c7cfb2a2a OpenDocument/ODT writer: use predefined styles. (#11672)
Previously the OpenDocument writer emitted a fresh automatic style
(L1..Ln, P1..Pn, T1..Tn) for nearly every list, list-item paragraph,
block quote, preformatted block, and inline text style.  This produced
large ODT files, made `--reference-doc` customization ineffective (the
user's predefined styles were never referenced), and gave each list its
own indentation independent of any containing block quote.

This commit teaches the writer to reference the predefined styles that
LibreOffice ships and that pandoc's reference.odt now exports:

- Bullet lists use `List_20_1`; ordered lists with default start and
  decimal format use `Numbering_20_1`.  Non-default ordered lists
  generate a single named override style (`Pandoc_Numbering_N`)
  memoised by (ListNumberStyle, ListNumberDelim); a non-default start
  value with the default format is expressed via `text:start-value`
  on the `text:list` element instead of a new style.
- List-item paragraphs use `List_20_Bullet[_Tight]` and
  `List_20_Number[_Tight]`.  The Tight variants are pandoc-specific
  (zero top/bottom margin) and are injected into the user's
  reference.odt if missing, just like the Skylighting token styles.
- Block quotes use the predefined `Quotations` paragraph style
  directly.  Nested block quotes use a single automatic style that
  inherits from Quotations and only adds extra margin-left, so a list
  inside a block quote now inherits its container's indent (#2747).
- Preformatted blocks use `Preformatted_20_Text` directly.
- Emphasis, Strong, Strikeout, Subscript, Superscript and Code spans
  use the predefined `Emphasis`, `Strong_20_Emphasis`, `Strikeout`,
  `Subscript`, `Superscript` and `Source_20_Text` text styles.
- `paraStyle`/`paraStyleFromParent` no longer emit a wrapper automatic
  style when its only attribute would be `parent-style-name`; the
  parent name is returned directly.

Closes #9136.
Closes #5086.
Closes #2747.
Closes #3426.
Closes #7336.

Co-authored by: Claude Opus 4.7.
2026-05-27 17:35:39 +02:00
John MacFarlane 9c83002851 Use MathJax v4 in default HTML templates.
See #11669.
2026-05-26 22:44:17 +02:00
John MacFarlane d37f306299 Man reader: better handling of .TP macro.
We parse these as DefinitionList items, but we previously
sometimes stopped prematurely in including material in the
definition.  We should include everything until we hit a new
indentation-changing macro.

Closes #11668.
2026-05-26 12:57:29 +02:00
John MacFarlane 646eeb6614 gridTable: fix calculation of column widths for default columns.
This fixes a bug which produced too-narrow columns in some cases.

Closes #11664.
2026-05-23 18:09:46 +02:00
nibras shami 0640c4c985 EPUB writer: support multiple EPUB versions for raw content (#11628).
This change ensures that raw content marked `epub2` will appear in (only) EPUBv2 output
and content marked `epub3` will appear in (only) EPUBv3 output.
2026-05-17 11:02:34 +02:00
John MacFarlane 73a48d2670 HTML reader: parse aside as a Div.
(Instead of using raw HTML.)

The "aside" class is added to the Div.
Also, add "header" class to Divs created from headers.

See #11626.
2026-05-14 11:58:19 +02:00
John MacFarlane b43762cdc4 Error messages: use single quotes around paths and format names.
Closes #11645.
2026-05-13 17:15:34 +02:00
John MacFarlane b8a0e5e85d Roff reader: handle \ line continuation in table cells.
Closes #11635.
2026-05-11 12:30:20 +02:00
John MacFarlane 859f62685a HTML templates: include pandoc-version in generator meta tag.
Closes #11624.
2026-05-07 12:39:06 +02:00
John MacFarlane 7825bd001c Markdown reader: don't produce empty Raw element with --strip-comments.
Closes #11625.
2026-05-07 12:10:23 +02:00
Andrew Dunning 8e6aecfebc Markdown reader: fix quotes in inline notes (#11614)
When parsing an inline note (`^[...]`) inside a quoted span,
`stateQuoteContext` was still set to `InSingleQuote`/`InDoubleQuote`,
so quotes within notes failed to parse as `Quoted` nodes.
Fix this by wrapping the note body parser in
`withQuoteContext NoQuote`.

Closes #11613.
2026-05-04 12:56:56 +02:00
John MacFarlane 45c31661b2 LaTeX reader: evaluate theorem name when used...
rather than evaluating it when the `\newtheorem` command
is encountered. It may include macros only defined later.
Closes #11608.
2026-05-02 13:07:00 +02:00
Keenan Brock 2b5600fd0c HTML styles: make screen-only CSS conditional (#11606)
Styles unconditionally emits css that uses screen-only properties.
Paged-media engines (weasyprint, prince, pagedjs) have no viewport
and issue warnings. Fix it to hide these properties from the engines.

Closes #11524.
2026-05-02 12:43:40 +02:00
John MacFarlane 672e745839 LaTeX reader: put identifier from label on table attributes...
rather than adding an enclosing Div.

Closes #11604.
2026-05-01 00:15:40 +02:00
John MacFarlane f74179a5d8 Typst reader: Fix issue parsing figure inside rotate or box.
Closes #11598.
2026-04-24 10:55:52 +02:00
John MacFarlane c15e062867 Markdown reader: allow spaces inside attributes in super/sub.
Closes #11589.
2026-04-18 23:19:15 +02:00
John MacFarlane aa571d2c41 Add --typst-input CLI option.
This allows one to pass parameters to typst, which are available
at `sys.inputs`, just as `typst` itself does with its `--input`
option.

[API changes]

* ReaderOptions has a new field `readerTypstInputs`.
* Opt has a new field `optTypstInputs`.

Closes #11588.
2026-04-18 13:05:35 +02:00
John MacFarlane 38a23550bb Typst writer: newline after #set text directive.
This ensures that blocks such as lists are parsed correctly
after a `set text`.

Closes #11583.
2026-04-15 22:25:11 +02:00
John MacFarlane 3fc374908c Docx reader: don't look to ext tags for image extent.
This was added in 7ff1b798c4
but was mistaken and could cause images to be parsed with
the wrong sizes.

Closes  #11580.
2026-04-13 12:04:02 +02:00
John MacFarlane 381b82e4a3 Docx writer: fix FirstParagraph style lost after heading with footnote.
When a heading contained a footnote, processing the footnote's block
content would consume the stFirstPara flag, causing the following
paragraph to incorrectly receive BodyText style instead of
FirstParagraph. Fix by saving and restoring stFirstPara around
footnote block processing.

Closes #11573.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-09 21:13:28 +00:00
John MacFarlane a6486391e1 Markdown writer: escape ::: to avoid triggering unintended divs.
Closes #11571.
2026-04-09 10:51:15 +02:00
John MacFarlane 134296c541 Fix test suite parallel execution failures.
MediaBag test used `inDirectory` (which calls `setCurrentDirectory`),
changing the process-wide CWD and causing other parallel tests
to fail with "does not exist" errors on relative paths.
Replace with absolute paths so the test no longer changes CWD.

Closes #11566.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 11:18:49 +02:00
John MacFarlane 7aca987b95 MediaWiki writer: handle some technically malformed URLs.
E.g. `http://example.com/#/#room` and `http://example.com/##`. Closes #11562.
2026-04-04 15:27:01 -04:00
John MacFarlane df61b8b1a9 MediaWiki writer: fix escaping to avoid lists.
For paragraphs beginning with literal `#`, `*`, or other things
that would otherwise produce lists, we insert `<nowiki></nowiki>`
rather than (as previously) `\`. `\` does not work to escape
these.

Closes #11563.
2026-04-04 15:12:23 -04:00
John MacFarlane 7777de6adb BibLaTeX inbook should be CSL book, not chapter.
Closes #11552.
2026-03-27 23:56:08 -04:00
John MacFarlane fcd8eae940 Man writer: don't run together successive definitions...
in a tight definition list with multiple definitions
after a term. Closes #11547.
2026-03-22 15:41:37 +01:00
John MacFarlane 397fef7900 LaTeX template: Define \xmpquote if not defined.
`\xmpquote` is defined by the hyperref driver hyperxmp; we need a
fallback for those who aren't using that.

Closes #11528.
2026-03-22 10:36:15 +01:00
John MacFarlane 8ce63ffe28 Mardkown writer: fix spacing issues with definition lists.
- Properly handle the case where the first item is an indented
  code block.  (Closes #11542.)
- Use correct indentation when `four_space_rule` extension is
  disabled.
2026-03-20 11:39:01 +01: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 ef6b669e25 Markdown reader: Fix bug with lists_without_preceding_blankline.
This was not properly implemented, causing some unintended
results. Closes #11534.
2026-03-17 19:37:08 +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
John MacFarlane c8ee9dc545 Docx reader: preserve non-textbox content when unwrapping textboxes.
Previously, when a w:p paragraph contained runs with textboxes,
the entire paragraph was replaced by just the textbox content,
discarding all other runs (including image-bearing runs).
Now we walk the paragraph's children in order, grouping
non-textbox content into copies of the original w:p and splicing
unwrapped textbox content in place, preserving the original order.

We also treat text inside a textbox containing an image as a
figure caption.  (One often finds captioned images of this
kind in docx files.)

Closes #11510.
Closes #6893.
Closes #11412.
Closes #5394.
Closes #9633.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-14 20:12:34 +00:00
Raymond Berger f0d05eb438 Docx reader: Recognize media inside textboxes (#11515)
Closes #11053.
2026-03-12 22:26:17 +01:00
John MacFarlane 80c704a9ac Typst writer: properly escape . after bracketed argument.
(When it might be mistaken for field access.)

Closes #11511.
2026-03-09 14:10:53 +01:00
Albert Krewinkel 40b525352d JATS writer: improve representation of divs
The writer now checks if the element used to represent (non-special)
divs has any `<boxed-text>` specific attributes. If it does, the writer
keeps wrapping the div contents in a `<boxed-text>`, as it did before.
Otherwise, the writer falls back to the more appropriate `<p>` element
or simply unwraps the div if the wrapping element wouldn't have any
attributes. The new behavior gives better semantic results in most
cases, as `<boxed-text>` should be used for text that "is outside the
flow of the narrative text", which doesn't apply to most divs.

"Special" divs, like those used to mark sections, are not affected by
this change.
2026-03-06 13:59:04 +01:00
massifrg 15ddf4124c ICML writer support for image object styles (#11498)
This change allows users to style images in InDesign bysetting the
`object-style` attribute in a pandoc Image, which is mapped to the
AppliedObjectStyle attribute in the Rectangle element around
an Image element in the resulting ICML.
2026-03-03 22:31:55 +01:00
John MacFarlane a6ab08da9f MediaWiki writer: use appropriate syntax for external images.
Note that they will only be rendered as images if an
option `$wgAllowExternalImages` is enabled in the MediaWiki instance.

Closes #11494.
2026-03-03 15:38:51 +00:00
John MacFarlane fd8d755f8a Markdown writer: escape literal & that would trigger entity.
Closes #11490.
2026-02-27 11:51:35 +01:00
Christophe Dervieux 7bd9dbecdc Revealjs writer: default scrollProgress to 'auto'.
RevealJS defaults scrollProgress to 'auto', but the writer was
setting it to true.  Use lookupMeta to distinguish between
MetaBool True, MetaBool False, and unset (defaulting to 'auto').
The template uses a helper variable scrollProgressAuto since
pandoc templates cannot distinguish a MetaString "auto" from
MetaBool True in a single variable.
2026-02-25 11:45:30 +01:00
Christophe Dervieux bf96353c48 Revealjs template: fix type rendering of scroll-view options.
Remove quotes from scrollActivationWidth (should be a number,
not a string).  Use $if/$else$ guard for scrollSnap so that
`false` renders as a boolean literal rather than the string
'false'.  Add /nowrap to scrollSnap and scrollLayout.
2026-02-25 11:45:30 +01:00
John MacFarlane a56d98f9c4 HTML styles template: avoid duplicate code selector.
Consolidate two clauses. Closes #11484.
2026-02-23 17:36:50 +01:00
John MacFarlane e270beac1a Docx writer: fix section breaks with --top-level-division.
Previously, the fix for #10578 (removing leading section break to avoid
blank first page) was implemented inside blocksToOpenXML, which is called
recursively for Div contents. Since makeSectionsWithOffsets wraps each
section in a Div, this caused ALL section breaks to be stripped, not just
the first one (#11482).

This commit fixes the issue by tracking whether we've processed the first
section header using a new stFirstSectionHeader state flag. Section breaks
are now correctly added between chapters/parts while still avoiding a
blank first page.

Closes #11482.
See also #10578.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-23 10:46:18 +00:00
John MacFarlane be5bafcfc9 Markdown writer: Fix rendering of alerts.
We only properly handled the case where the alert started with
a paragraph, but it can start with a list or other block type.

Closes #11479.
2026-02-18 10:21:41 +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
Jan Tojnar 84e39ff36f Odt reader: Support Preformatted Text from pandoc writer
pandoc generates a separate style class like P123 for each paragraph,
inheriting the desired style using `parent-style-name`.

Previously, we did not support that but it is pretty easy to add.
Though for simplicity this fix does not extend to finding the parent
style recursively when deeper hierarchies are involved.
2026-02-16 13:54:34 +01:00