1310 Commits

Author SHA1 Message Date
John MacFarlane f6edf03303 Shared: Improve makeSections.
Previously it would sometimes create doubled section divs.
By leaving the inner heading's id on the heading itself, and
then consolidating the inner and outer section divs, we can
avoid this undesirable result.

Closes #11745.
2026-07-07 20:58:33 +02:00
John MacFarlane db7efddf74 Texinfo writer: fix spacing bug around HorizontalRule.
Closes #11749.
2026-07-07 16:58:44 +02:00
Can H. Tartanoglu 57639391fc ODT writer: image anchoring, percent dimensions, text width resolution (#11746)
Inline images now emit `text:anchor-type=as-char` on their `draw:frame`,
anchoring the frame as a character so it flows with the surrounding text.
Without this, consumers default to paragraph anchoring and float the frame
beside (or after) the following paragraph.

When both width and height are given and the width is a percentage,
the width is now resolved against the reference document text area width,
mirroring how the docx writer derives its print width from the reference docx
section properties. The height follows the aspect ratio.
2026-07-04 18:52:14 +02:00
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 612e143fbe DokuWiki reader: skip non-cell content after table row.
Closes #11739.
2026-06-29 19:28:54 +02:00
John MacFarlane 1c22498269 LaTeX writer: fix footnotes in def list headings.
Closes #8240.
2026-06-29 11:40:30 +02:00
John MacFarlane 197ea8e8bd RST reader: treat undefined substitution references as plain text.
This mirrors rst2html behavior. Closes #11727.
2026-06-23 12:06:27 +02:00
John MacFarlane 58929eb70c Markdown writer: in YAML metadata, put double quotes around...
...strings that are numbers beginning with 0 or ending with 0 and
having a decimal point.  Otherwise they will read as YAML numbers
and potentially be modified (e.g. 3.10 -> 3.1).

It would be better to fix this on the reader side, but since
we use a standard YAML parser it's hard to see how.

Closes #11715.
2026-06-21 15:15:42 +02:00
John MacFarlane ec4fb91049 Typst reader: support auto_identifiers extension.
Headings without an explicit label can now be assigned automatic
identifiers based on the heading text, making them linkable in a
generated table of contents.  The extension is available for the
typst reader but is off by default; enable it with
`-f typst+auto_identifiers`.  The related `gfm_auto_identifiers` and
`ascii_identifiers` extensions are also made available.

Closes #11041.

Text.Pandoc.Readers.Typst.Parsing: PState gains sOptions,
sIdentifiers, and sLogMessages fields, and now has
HasReaderOptions, HasIdentifierList, and HasLogMessages
instances, allowing reuse of the shared registerHeader. (Not an
API change.)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-13 23:38:51 +02:00
John MacFarlane 8a52ac1493 Markdown writer: improve identification of code language class...
...by looking it up in the syntax map. (Previously we just used
the first, excepting `sourceCode`.)

Closes #11701 (together with previous commit).
2026-06-12 21:01:25 +02:00
John MacFarlane 888a0062f1 Fix test for #11689 (use native) 2026-06-09 08:42:09 +02:00
John MacFarlane 5566a6bf3c Docx reader: improve horizontal rule detection.
Previously we failed to detect horizontal rules when the
underlying XML contained text elements for semantically
insignificant whitespace. We also failed to handle the case
where a paragraph contains text and has a bottom border
property: this seems to be what Word does when you insert
a horizontal rule, e.g. by typing a series of hyphens or #
characters.

Closes #11689.
2026-06-08 23:49:22 +02:00
John MacFarlane aafcfa14b0 LaTeX reader: handle \hypertarget with one braced parameter.
This seems to work in LaTeX, no doubt because a single token
is consumed as the target text parameter.

Closes #7418.
2026-06-08 19:22:24 +02:00
John MacFarlane 16d66edb2a Typst writer: fold lang into pickTypstAttributes.
This ensures that `lang` attributes will be set for both
Divs and Spans. Closes #11673.
2026-06-06 22:49:45 +02:00
John MacFarlane 9d68bb83a7 T.P.Writers.Shared; htmlAttrs - don't add data- prefix for markdown.
This is necessary for the `markdown_attribute` extension to
work properly. Closes #11685.
2026-06-05 17:17:22 +02:00
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
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 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 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 7825bd001c Markdown reader: don't produce empty Raw element with --strip-comments.
Closes #11625.
2026-05-07 12:10:23 +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
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 a6486391e1 Markdown writer: escape ::: to avoid triggering unintended divs.
Closes #11571.
2026-04-09 10:51:15 +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 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 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 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
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 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
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 3c56088b4e LaTeX reader: support \footnotemark and \footnotetext (#11450).
These commands allow separating the footnote mark from its content,
useful in tables, minipages, and other contexts where \footnote
cannot be used directly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Closes #11450.
2026-02-14 14:22:15 +00:00
John MacFarlane 04848401d5 Typst writer: fix escaping of quotes.
All quotes should be escaped the same way with `smart`; previously
we were treating right and left single quote differently.

Closes #11463.
2026-02-13 11:01:37 +01:00
John MacFarlane 5db6c52fbd Textile reader: handle block content in cells.
Closes #11455.
2026-02-12 21:21:14 +00:00