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.
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>
...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.
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.
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.
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>
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.
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>
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.
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.
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.
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.
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>
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.
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.
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.
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.
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.
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.
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.
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.
- 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.
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.
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>
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>
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>
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>
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>
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.