Commit Graph

1232 Commits

Author SHA1 Message Date
John MacFarlane 28d3dbfec9 Implement reset-citation-positions class on headings.
When the `reset-citation-positions` class is added to
a top-level heading, `--citeproc` will reset position
information at that point in the document. This is needed
in order to ensure that the first citation in a chapter
to a work that has been cited in a previous chapter will
not be in abbreviated form.

Requires a dependency on a development version of citeproc.
2025-12-06 18:33:17 +01:00
John MacFarlane a3ab4b8545 HTML reader: parse inline style elements as RawInline.
This is a cleaner fix to #10643 than the reverted commit 7fe8c92.

Styles are not stripped, but with this change they will not
interfere with inline parsing.

Closes #11246.
2025-12-05 11:14:11 +01:00
John MacFarlane 41b14dc891 RST reader: fix definition lists where term ends with -.
This reverts some old code giving special treatment to lines
ending in hyphens; I don't understand why it was there, because
rst2html does not seem to do this.

Closes #11323.
2025-12-05 10:46:24 +01:00
John MacFarlane b9b6ba0805 Texinfo writer: improve handling of certain code blocks.
MediaWiki, for example, will parse a code block containing
formatting as a sequence of Code elements separated by
LineBreaks. For this we now use a texinfo example block.

Closes #11312.
2025-12-02 12:04:36 +01:00
Ezwal fc07b06851 Docx reader: Handle REF link instruction (#11296)
This PR aims to handle a common run field instruction (fieldInstr)
from docx format :  REF, specifically those with the "link" switch \h.

In word software, you can create REF field instruction with the
Cross-reference button. You can create cross-reference to
many things such as Equation, Table, Title...
2025-11-30 13:49:58 +01:00
Tuong Nguyen Manh 58e741a0d6 ANSI writer: Apply row spans in tables (#11294)
The ANSI writer is now able to keep track of row spans and apply them in rows.

[API change] T.P.Writers.Shared:
Add functions `insertCurrentSpansAtColumn`, `takePreviousSpansAtColumn`
and `decrementTrailingRowSpans` for applying and keeping track of
RowSpans over multiple rows.

Fixes: #10149
2025-11-30 13:20:30 +01:00
John MacFarlane af9443a981 RST reader: correctly handle intraword emphasis.
Closes #11309.
2025-11-30 12:16:40 +01:00
John MacFarlane 814bdbdbef Better handling of \makeatletter in parsing raw LaTeX.
Closes #11270.
2025-11-04 14:30:05 +01:00
John MacFarlane 97f7a93460 Add command test for #9953. 2025-11-04 14:08:57 +01:00
Emmanuel Ferdman b106dca069 LaTeX reader: fix spurious paragraph breaks in math environments (#11265)
Previously, a math environment with extra space before the
`\end` would get rendered with a blank line, which LaTeX
treats as a paragraph break.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-11-04 09:42:27 +01:00
John MacFarlane 74f583847f LaTeX reader: fix bugs in raw LaTeX parsing.
Fix `rawTeXParser`.  Make macro expansion in raw LaTeX depend on
the setting of the `latex_macros` extension.  Previously macros
were always expanded, even in raw TeX in markdown. In addition,
there was previously a bug that caused content to be garbled
in certain cases.

Closes #11253.

Handle `ifstrequal` at a lower level, like the other `if` commands.
See #11253.
2025-11-03 23:16:48 +01:00
Tuong Nguyen Manh 594f109956 asciidoc writer: Add more table features (#11267)
This adds the following table features:

- row span and column span
- footer row
- individual horizontal cell alignment

[API change] T.P.Writers.Shared: Add functions `allRowsEmpty` and
`tableBodiesToRows` from the RST writer for reuse in other writers.

Also fix hlint warning about `unzip` from `NonEmpty`:
The exported polymorphic function will become
monomorphic in the future. Restrict the `NonEmpty`
import to use the Prelude `unzip` function.
2025-11-03 20:30:33 +01:00
John MacFarlane 1edd5cde72 LaTeX writer: improve handling of math environments in tex math.
Previously the special handling added for #9711 worked only
when the math element did not contain spaces before the
math environment.

Closes #11266.
2025-11-02 15:37:54 +01:00
John MacFarlane b69e9dbb81 Typst reader: handle document metadata and #title.
See jgm/typst-hs#80.

Note that previously, the typst reader never returned document
metadata.  Now it does, even if the typst document does not contain
a `#title` function that would result in actually printing the
title block.
2025-10-30 20:02:28 +01:00
Albert Krewinkel 13a5b1a4df Org reader: parse parameter lists on unknown blocks.
The reader tries to parse the rest of the opening line of a block, e.g.,
`#+begin_myblock …`, as a parameters list. It first assumes that the parameters
are in lisp-style (`:key value`), then alternatively tries to read python-style
key-value pairs (`key=value`) and falls back to reading the entire remaining
line as a single `parameter` attribute.

This method is also applied to dynamic blocks.

Closes: #11188
2025-10-18 17:35:23 +02:00
John MacFarlane eb9bfb6b96 Fix #6959 test so it works on Windows. 2025-10-16 11:17:35 +02:00
John MacFarlane d4dd5e9ab9 Docx writer: properly handle nested comment spans.
Patch credit: @mmourino.

Closes #8189. Closes #6959.
2025-10-15 23:33:04 +02:00
TuongNM 80ccc78a52 RST writer: Don't use simple tables with RowSpans (#11214) 2025-10-14 19:07:02 +02:00
John MacFarlane d81ee85952 RTF reader: improve hyperlink parsing.
Closes #11211.
2025-10-13 20:23:22 +02:00
John MacFarlane 3d6439ad15 Typst writer: Escape open paren after non-space.
This fixes an issue that occurs if an open paren comes
right after e.g. `#strong[test]`.

Closes #11210.
2025-10-13 12:11:29 +02:00
John MacFarlane d8354618c4 LaTeX writer/template: small fix for unnumbered tables.
This improves on commit e13aa5c015,
which worked only for recent versions of longtable.

For older versions, we need to define a dummy counter `none`.

Closes #11201.  Thanks to @priiduonu for the solution.
2025-10-06 23:04:40 +02:00
John MacFarlane e87b86261f Typst writer: don't add semicolons as much.
Previously we added semicolons after inline commands not
followed by spaces, but mainly this was to deal with one issue:
the presence of a semicolon after an inline command, which
would be swallowed as a command separator (#9252).

This commits adopts an approach that should avoid so many
superfluous semicolons: it escapes semicolons that might come
right after a command.  See #11196.
2025-10-05 16:33:03 +02:00
TuongNM 7571187792 LaTeX writer: Fix strikeout in links (#11192)
As in #1294 \url and \href need to be protected
inside an mbox for soul commands.

Closes #9366.
2025-10-04 19:21:18 +02:00
John MacFarlane e201e3370a Markdown tables: implement table_attributes extension.
When `table_attributes` is enabled (as it is by default for
pandoc's Markdown), attributes can be attached to a table by
including them at the end of the caption. Previously the writer
would emit an identifier in this position, but the reader didn't
handle it. Now arbitrary attributes are allowed, and they work in
both the reader and writer.

Closes #10884.

[API change]: Text.Pandoc.Extensions: Add `Ext_table_attributes`
constructor for `Extension`.
2025-10-02 13:37:53 +02:00
TuongNM ca0fc7dc55 RST writer: Add col spans for simple tables (#11173)
Closes #10127.
2025-09-29 11:53:24 +02:00
John MacFarlane 95326e21e6 Add shorthands variable for LaTeX output.
If true, pandoc will allow language-specific shorthands
when loading babel.

Closes #11160.
2025-09-24 22:25:07 +02:00
John MacFarlane 9024df9348 RST writer: ensure blank line before directives.
Closes #11162.
2025-09-24 21:32:31 +02:00
TuongNM bdab9915ad OpenDocument writer: Add missing table elements (#11157)
Add missing header rows after the first one,
footer rows as well as TableBody header rows.

Also apply hlint suggestions to use Down and fuse mapM/map.

Closes #10002.
2025-09-20 21:05:29 +02:00
John MacFarlane 70393b4235 RST reader: fix regression in simple table parsing.
Closes #11150.
2025-09-18 11:52:22 +02:00
John MacFarlane d820620ccd Docx reader: properly calculate table column widths.
Previously we assumed that every table took up the full text
width. Now we read the text width from the document's
sectPr.

Closes #9837.
Closes #11147.
2025-09-17 14:24:33 +02:00
John MacFarlane e13aa5c015 LaTeX writer: ensure that unlabelled tables don't increment counter.
Closes #11141.
2025-09-16 18:01:07 +02:00
John MacFarlane cf760c7f66 Markdown reader: Improve superscript/subscript/inline note parsing.
We do not allow inline notes to be followed by `(` or `[`.
Otherwise, we parse inline notes before superscripts.
This fixes #8652.

Also, the sub/superscript parsers have been adjusted so that they
really exclude unescaped spaces (as they did not before, when the
spaces occurred in nested inlines). See #5878 for comment.
2025-09-16 12:46:25 +02:00
John MacFarlane 1f3163a638 LaTeX reader: ignore \pandocbounded.
Third issue in #11140.
2025-09-15 10:50:04 +02:00
John MacFarlane f7059959ed Markdown writer: improve handling of implicit figures.
Allow implicit figures when alt text differs from caption
(in this case, we use an image attribute to add the alt).

Closes #11140.
2025-09-15 10:50:04 +02:00
John MacFarlane 9c36d884d5 RST reader: parse :alt: on figure.
Also give a better default if `alt` is not specified, using
the stringified caption rather than the filename.

Partially addresses #11140.

Add failing test case for Markdown writer issue in #11140.
2025-09-15 10:50:04 +02:00
TuongNM e2f088f4e5 LaTeX writer: Protect VERB in caption (#11139)
Also apply hlint suggestions for fewer imports and
moving brackets to avoid $.
2025-09-15 10:28:57 +02:00
TuongNM 5eb25ab448 Markdown reader: Fix simple table alignment (#11136)
Take wide characters into account when determining the alignment.
2025-09-12 11:44:34 +02:00
Raymond Berger c93acab035 Add support for reading typst pagebreak (#11126)
The pagebreak is parsed as a HorizontalRule inside a wrapper Div with class `page-break`.

Closes #11101.
2025-09-10 09:56:16 +02:00
John MacFarlane 71a0c5c61e Markdown writer: use approximate pipe tables when it's the only option.
If we have a table with row/colspans that can rendered as an
approximate pipe table (without row/colspans), and no other table
format is enabled that could render the table, we fall back to
an "approximate" pipe table, with no row/colspans.

Closes #11128.
2025-09-10 09:49:06 +02:00
Tuong Nguyen Manh 47e1cc46c6 RST Reader: Add col spans for simple tables
[API change] Text.Pandoc.Parsing: New functions `tableWithSpans`,
`tableWithSpans'`, `toTableComponentsWithSpans` and
`toTableComponentsWithSpans'` take a list of lists of
(Blocks, RowSpan, ColSpan) to parse a Table with different RowSpan and
ColSpan values accordingly.
New helper functions `singleRowSpans` and `singleColumnSpans` help set
all RowSpans or ColSpans to be 1 in case the table format only allows
setting one or the other.
2025-09-09 10:27:18 +02:00
Albert Krewinkel 36bbdc667a T.P.Writers.Shared: add new function removeLinks.
The function converts links to spans. It is used, for example, to avoid
nested links.

The HTML writer used to put the description of nested links into small
caps, but uses a simple *span* now.
2025-09-09 10:26:05 +02:00
John MacFarlane 536d548335 Docx reader: better handling of AlternateContent.
This revises the solution to #9214 in commit 2e8ecb3 in order to
handle a standard Word way of inserting emojis.

Closes #11113.
2025-09-06 10:48:22 +02:00
John MacFarlane 0dc31a470f Fix test case that changed because of addition of nocase span. 2025-09-03 18:06:27 +02:00
John MacFarlane 037a6e81e2 T.P.Citeproc.BibTeX: Protect case in periodical titles.
Thus, for example, `{npj} Quantum Information` should translate as
`[npj]{.nocase} Quantum Information`.

Closes #11048.
2025-09-03 12:56:58 +02:00
Albert Krewinkel e0acb24528 Refactor highlighting options [API Change]
A new command line option `--syntax-highlighting` is provided; it takes
the values `none`, `default`, `idiomatic`, a style name, or a path to a
theme file. It replaces the `--no-highlighting`, `--highlighting-style`,
and `--listings` options.

The `writerListings` and `writerHighlightStyle` fields of the
`WriterOptions` type are replaced with `writerHighlightStyle`.

Closes: #10525
2025-09-02 17:50:47 +02:00
TuongNM 3e2c029a77 RST Reader: Support multiple header rows (#11057)
[API change] Text.Pandoc.Parsing: `tableWith` and `tableWith'` now
return a list of lists of Blocks, rather than a list of Blocks, for the
header rows, allowing for multiple header rows.

Closes #10338.
2025-09-02 13:12:34 +02:00
John MacFarlane f3c7a931b4 Update default.csl from new chicago-author-date.csl. 2025-09-02 12:42:16 +02:00
John MacFarlane 65c698a5bb Use latest dev citeproc. 2025-09-02 11:26:10 +02:00
John MacFarlane 4d545b69fe Change latex-pos to latex-placement. 2025-09-02 08:39:47 +02:00
John MacFarlane f865b3bc4b Typst reader: properly resolve image paths in included files.
Closes #11090.
2025-08-30 00:04:23 +02:00