Commit Graph
9380 Commits
Author SHA1 Message Date
John MacFarlane 1cc6fec234 ImageSize: correctly handle percentage width, height on svg.
Previously we were getting image size of 0 when a percentage
was specified for width or height on SVG.  With this change,
we simply ignore these percentages (becaues ImageSize doesn't
know the size of the containing element).

Closes #11530.
2026-03-17 09:49:29 +01:00
ˌbodʲɪˈɡrʲimandGitHub f10ee0eec3 LaTeX reader: support supertabular environment (#11523) 2026-03-14 22:25:19 +01:00
John MacFarlaneandClaude 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
John MacFarlane 8aa7a08574 Docx writer: don't depend on extractTarget from Docx reader. 2026-03-12 23:51:21 +01:00
John MacFarlane 244528e044 Docx reader: properly handle media stored with packaged-rooted paths...
...such as /media.  This can be produced by the online version
of Word. (Desktop Word uses paths relative to word/.)  With this change,
media stored at an absolute path will be stored with its original
name and not given a SHA1-based name.

Closes #11518.
2026-03-12 23:28:54 +01:00
Raymond BergerandGitHub 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
massifrgandGitHub 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 MacFarlaneandClaude Opus 4.5 104344fe72 PPTX writer: register content type for embedded fonts.
When a reference document contains embedded fonts (.fntdata files),
the content type was not being registered in [Content_Types].xml,
causing PowerPoint to flag the output as corrupted.

Closes #11492.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-28 14:07:54 +00:00
John MacFarlane fd8d755f8a Markdown writer: escape literal & that would trigger entity.
Closes #11490.
2026-02-27 11:51:35 +01:00
Pascal WaglerandGitHub 72b62843c1 EPUB 3 update allowed values for metadata identifier.scheme (#11485)
- Update allowed values for metadata `identifier.scheme` from ONIX codelist  issue 72.
- Change some `identifier.schema` allowed values to better align with ONIX codelist.
- Update manual.

Closes #11481.
2026-02-25 22:03:33 +01:00
John MacFarlane f5d8079ad7 Tweak to #11487 - Use fromContext instead of lookupMeta.
This ensures that things will work even if the variable is
set using `--variable`.

Closes #11486.
2026-02-25 11:55:58 +01:00
Christophe DervieuxandJohn MacFarlane 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
John MacFarlaneandClaude Opus 4.5 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
Jan TojnarandJohn MacFarlane 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
Jan TojnarandJohn MacFarlane b4f71f7ef0 Odt reader: Support Preformatted Text style
LibreOffice uses `Preformatted_20_Text` as the default style for
code listings etc. Let’s detect if a paragraph has the `style-name`
and convert it to `CodeBlock` if it is the case.

Unfortunately, pandoc itself generates a separate style class like P123
for each paragraph so we will not yet support code listings from documents
generated by pandoc itself.

Closes #4841.
2026-02-16 13:54:34 +01:00
Jan TojnarandJohn MacFarlane 8b994e01a5 Odt reader: Add block smushing logic
This will be necessary once we add support for parsing code blocks.
Just like in Word/OOXML, those are typically represented as one paragraph
per line of code, each having `Preformatted Text` as style name.
2026-02-16 13:54:34 +01:00
Jan TojnarandJohn MacFarlane edd6865f1c Odt writer: Rename inline source class to match LibreOffice
Rename the text style we use to represent `Code` inlines from
`Source_20_Text` to `Source_Text`.

This is the same name LibreOffice Writer uses so it will be recognized
by the Character Styles section of the Styles menu.

Closes #3390.
2026-02-16 13:54:34 +01:00
Jan TojnarandJohn MacFarlane 4d7669666a Odt reader: Recognize Preformatted_20_Text style
This is used by LibreOffice, and we will switch to that as well.
2026-02-16 13:54:34 +01:00
Jan TojnarandJohn MacFarlane 9f4a303587 Odt reader: Normalize parametric type names 2026-02-16 13:54:34 +01:00
Tuong Nguyen ManhandGitHub 1e4fc7254b ODT Reader: Fix relative linked images (#11467)
Like with relative links ODT adds a `../` to relative linked images
which needs to be removed.

Fixes #11369.
2026-02-15 18:20:47 +01:00
John MacFarlaneandClaude Opus 4.5 94dc2de439 EPUB writer: add cover metadata for EPUB3.
Previously, the <meta name="cover" content="..."> element was only
generated for EPUB2. This element is used by file managers to display
cover images as thumbnails. Now it is also generated for EPUB3,
allowing file managers to show cover thumbnails for EPUB3 files as well.

Used epubcheck to verify that the addition of this element does
not compromise EPUB v3 validity.

Closes #11469.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 17:19:40 +00:00
John MacFarlane 93efd39f42 T.P.Writers.GridTable: normalize tables.
Previously, if an invalid table was passed to `toTable`, an
array index error could be raised. Normalizing the table forces
it into a shape that won't allow this error.

Closes #8102.
2026-02-15 18:11:24 +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
Jan TojnarandGitHub 3b9a47d02e readers/docx: Support w:gridBefore table row property (#11464)
Table rows in Docx files can use `w:gridBefore` property to specify
a number of extra empty table cells to be inserted at the beginning
of a row. Without this, table columns in tables using the element
will become misaligned.

https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.gridbefore?view=openxml-3.0.1

In the worst case, this can lead to cells at the end of some rows
to be dropped by the parser.

The test file was produced as follows based on
the “3GPP TS 24.282 V19.5.0 (2025-12)” document obtained from
<https://www.3gpp.org/ftp/Specs/archive/24_series/24.282/24282-j50.zip>
where I encountered the issue:

1. Extracted the `document.xml`.
2. Formatted it with `xmllint --format`.
3. Found the raw XML for “Table 15.2.13-2: Payload content type”.
4. Removed `w:rsid*` and `w14:*` attributes, and `w:pStyle` elements.
5. Replaced the context of `test/docx/raw-blocks.native`.
6. Used pandoc to generate the docx.
2026-02-14 14:28:03 +01: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
John MacFarlane 35638d965f Typst reader: Handle bibliography command.
If this is present, a bibliography section is added to the
document and the bibliography paths are added to `bibliography`
in the metadata. This sets things up for using `--citeproc`.

Closes #11460.
2026-02-12 16:34:33 +00:00
John MacFarlane a0448c7168 Typst writer: improve handling of data: URIs in images.
Instead of using an SVG with a link containing the data URI
(the solution of #10460), we can now simply produce a `bytes`
object with the requisite bytes. Typst figures out the format
automatically.
2026-02-09 17:03:05 +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
John MacFarlane 8cdb31d6e0 T.P.Error: define displayException for PandocError.
This is a behavior change, not an API change, since there
was already a definition that defaulted to using Show.
The change here is that we use renderError for a more human-readable
version.
2026-01-31 10:59:13 +01:00
Jacob LarkinandJohn MacFarlane 89d78b3ab7 Enhance variable expansion in defaults files
- Factor out expansion logic into expandVars and expandEnv for better
  maintainability and reuse.
- Ensure the '.' variable correctly resolves to the directory of the
  current defaults file, enabling relative paths in inherited defaults.
- Expand environment variables in 'data-dir' and use the expanded
  path when resolving child defaults.
- Allow environment variable expansion within 'defaults' file paths.

These changes make the defaults system more flexible for hierarchical
configurations without breaking backward compatibility.

Closes #8024.
2026-01-31 10:54:59 +01:00
John MacFarlane 818c840e10 Allow defaults files to be either JSON or YAML. 2026-01-31 10:32:51 +01:00
John MacFarlane 828382ba65 Revise change to --extract-media.
An earlier change added the feature that if the specified file
ends in .tar, a tar archive is created instead of a directory.
This has now been changed to create a zip archive if the filename
ends in .zip.
2026-01-30 19:43:32 +01:00
John MacFarlane c8aa6c2a38 Markdown reader: support alerts extension for pandoc markdown.
It is not enabled by default.

Closes #9716.
2026-01-27 12:44:43 +01:00
John MacFarlane 8191d06aff DocBook reader: omit empty title when not required.
Closes #11422.

This affects example and sidebar elements.
2026-01-27 10:20:31 +01:00
John MacFarlaneandClaude Opus 4.5 f0991cfcbb Reveal.js writer: add idiomatic highlight.js support.
Closes #11420.

When using `--syntax-highlighting=idiomatic` with reveal.js output,
pandoc now generates HTML compatible with reveal.js's built-in
highlight.js plugin:

- Code blocks use `<pre><code class="language-X">` format
- The template loads highlight.js CSS, JS, and RevealHighlight plugin
- Theme defaults to "monokai", configurable via `highlightjs-theme`
   variable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 13:53:38 +00:00
John MacFarlane 6212407eea MediaWiki writer: improve blank space around div elements.
This is merely cosmetic.

Closes #11417.
2026-01-24 14:53:08 +00:00
John MacFarlaneandClaude Opus 4.5 154b36a05e MediaWiki writer: use Doc Text instead of Text for document construction.
This refactors the writer to use Text.DocLayout combinators (vcat, hcat,
literal, blankline, cr, chomp) for building output, following the pattern
used by other text format writers (RST, Markdown, Man). This enables
better control over line spacing and paragraph separation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 14:32:24 +00:00
John MacFarlaneandClaude Opus 4.5 52120f92a6 Docx writer: replace generic XML traversal with direct path navigation.
Instead of using Data.Generics `everywhere` to traverse the entire XML
tree when setting language attributes, navigate directly to the known
path w:docDefaults/w:rPr/w:lang. This is more efficient and removes the
dependency on Data.Generics (mkT, everywhere).

The new `modifyAtPath` helper function takes a list of predicates that
match element names at each level of the path and modifies only the
target element.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:34:03 +01:00
John MacFarlaneandClaude Opus 4.5 94efb21520 Docx writer: refactor writeDocx into helper functions.
Extract 15 helper functions from the monolithic writeDocx function
to improve code clarity and maintainability. The function is now
organized into clear phases with well-typed helpers for each task:

- loadArchives: Load reference and distribution archives
- extractPageLayout: Extract page dimensions from template
- extractRelationships: Parse and augment document relationships
- mkLangTransformer: Build language transformer for XML elements
- mkFootnotesEntry, mkCommentsEntry: Create XML entries
- mkContentTypesEntry, mkDocumentRelsEntry: Create manifest entries
- mkStylesEntry, mkNumberingEntry: Create document formatting entries
- mkCorePropsEntry, mkCustomPropsEntry: Create property entries
- mkPackageRelsEntry: Create package-level relationships
- collectReferenceEntries: Collect auxiliary entries from reference

Also adds module-level constants stdAttributes and settingsElementNames
for clarity. No functional changes; all existing tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:34:03 +01:00
John MacFarlane b45f6cf86a HTML slide formats: make . . . pause work in nested blocks.
Closes #8715. Closes #7201. Closes #7582.
2026-01-23 16:31:11 +01:00
John MacFarlane c8ad2752c4 Markdown writer: properly handle tables with footers.
Closes #11416.
2026-01-23 10:51:29 +01:00
e07a3f3454 LaTeX writer: Add PDF standard support via DocumentMetadata (#11407)
Add `pdfstandard` metadata variable for specifying PDF standards
(PDF/A, PDF/X, PDF/UA) in LaTeX output. Uses LaTeX's \DocumentMetadata
command which requires LuaLaTeX.

- PDF version requirements are automatically inferred, but can be explicitly
  overridden.
- Automatic tagging for standards that require it (ua-1, ua-2, a-2a, a-3a).
- Warning for unsupported standards
- Documentation in MANUAL.txt (Variables for LaTeX, Accessible PDFs)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 20:00:57 +01:00
John MacFarlane 395fb2db43 Docx reader: look inside v:rect as well as v:shape.
This partially addresses #11412, but it would be nice to
add proper handling of the caption.
2026-01-22 19:23:36 +01:00
John MacFarlane d599154394 Markdown reader: allow superscripted spans.
These were being parsed as inline notes. Now we disallow an
inline note followed by attributes, as this is almost certainly
meant to be a span.

Closes #11409.
2026-01-21 17:04:49 +01:00