Make `--bash-completion` an alias of `--completion=bash`.
Reorganize option parsing code using a new data structure OptionSpec,
which can encode the type of completion needed by each option.
Add new unexported module Text.Pandoc.Completion.
Unexported module Text.Pandoc.CommandLineOptions: export OptionSpec.
Closes#8542.
See 185c29b4b2 which claims that
`block` can occur in inline contexts. I can no longer confirm
this and suspect that it may have been an unintended behavior
of earlier versions of typst, now fixed.
Closes#11814.
If this attribute is set, the writer will output a label.
(This overrides labels based on identifiers, when identifiers
are present.)
Note that labels in typst need not be unique and may be used to
style elements using show rules. For example, one can attach
an `excerpt` label to all Divs that are excerpts, and style this
using a show rule like `#show <excerpt>: set text(blue)`.
See discussion at #11794.
Previously ordered lists starting with a code block did not
round trip. Pandoc uses an indented code block, and according
to commonmark rules only one space is gobbled after the list
marker; however, pandoc added two. This has now been fixed.
An incidental change fixes an oddity in markua list indentation.
Closes#11762.
Given RST like
.. _target:
See |sub|.
.. |sub| replace:: `text <target_>`_
'pandoc -f rst -t html' produces
<div id="target">
<p>See <a href="##REF##target">text</a>.</p>
</div>
instead of the expected
<div id="target">
<p>See <a href="#target">text</a>.</p>
</div>
It formerly worked and regressed with c8fda8f4d ("RST reader: Use a new
one-pass parsing strategy."), release 3.6.
What happens is that during parsing pass 1 the `replace::` value `text
<target_>`_ is parsed to
Link nullAttr [Str "text"] ("##REF##target", "")
and is stored in ParserState's substitution table. Separately, '|sub|'
usage is parsed to
Link nullAttr [Str "|sub|"] ("##SUBST##|sub|", "")
and is stored in the document tree. resolveReferences then replaces the
placeholder in the document node with substitution table node during
walkM. However, the freshly substituted ##REF## placeholder was not
revisited further, and appeared unresolved in the output.
To fix it, we resolve the node recursively until the result contains no
more placeholder. We must protect from self-references to avoid
endless recursion.
Previously, when a slide contained bullet points before and after a
table, content would be split across multiple slides or use a two-column
layout that didn't preserve the source order.
This change:
1. Modified `splitBlocks'` in Presentation.hs to continue accumulating
content after tables instead of immediately splitting to a new slide.
2. When a slide has a table with surrounding text, use ContentSlide
(single column) instead of ContentWithCaptionSlide (two columns)
to preserve content order.
3. Added vertical stacking in Output.hs (shapesToElementsStacked) to
properly position multiple shapes (tables + text) within a content
area. Space is allocated proportionally based on content size
(paragraphs and table rows).
Closes#11433.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Chris Callison-Burch <ccb+github@upenn.edu>
`t2t` is now supported as an output format, producing Txt2Tags
markup (<https://txt2tags.org>). The writer covers headers, lists
(bullet, ordered, definition), tables, links, images, code blocks,
inline formatting, and raw txt2tags/HTML passthrough.
[API change]
Adds a new module Text.Pandoc.Writers.Txt2Tags, exporting
`writeTxt2Tags`. Also exported from Text.Pandoc.Writers.
Co-authored-by: luginf <alan@luginf>
When the `float` class is attached to a table, a standard
floating `table` will be generated instead of a `longtable`.
Placement can be specified via the `latex-placement` attribute.
This will help, especially, those who use two-column layouts,
since `longtable` is incompatible with these.
Small change to the default LaTeX template: the `caption`
package is included and a default spacing set between the caption
and the table.
Closes#1023.
Modified default template to remove custom show rule for
terms. Instead, we use a set rule to set hanging-indent.
For tight list items consisting of just one Plain block,
we no longer create a `#block` for the definition; this allows
it to remain on the same line as the term.
This just affects whether a blank line is emitted in the markup.
Note that pandoc's default template contains a show rule for
terms that will make these blank lines irrelevant, but this change
allows one to use tight lists with custom templates.
The fontsize is specified in a variable or metadata field
and passed through the renderer via a Reader monad.
Closes#11750.
Co-Authored-By: Claude <noreply@anthropic.com>
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.
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.
(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.
...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.
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>
When a reference document uses a non-standard namespace prefix for the
WordprocessingML namespace (e.g. `ns0` instead of `w`), `sectPr` elements
copied from the reference would retain the non-`w` prefix, producing
malformed XML in the output document. Similarly,
`extractPageLayout` only matched elements with prefix `w`, missing
`sectPr` elements with other prefixes. This is fixed by matching on the
namespace URI rather than the prefix, and normalizing the prefix to `w`
on all elements and attributes copied from reference-doc `sectPr`.
Some new tests have been added, and the test suite has been streamlined
using helper functions.
Word represents "restart numbering" on a style-based list by pointing
only the first item of the restarted list at a new `numId` that shares the
original list's abstract numbering definition but carries a
`w:startOverride`; the remaining items keep using the original `numId`.
Pandoc keyed list continuation and grouping on the `numId`, so the
restarted items continued the stale count from the earlier list (and
were split into a separate ordered list with the wrong start).
Key continuation and grouping off the `abstractNumId` instead (the real
running counter in Word), and treat `startOverride` as a restart that
resets the count.
Closes#8367.
Co-Authored-By: Claude <noreply@anthropic.com>
Word-95-style numbered and bulleted lists are encoded with a
`{\pntext ...}` auto-number destination at the start of each list
paragraph plus a `{\*\pn ...}` destination describing the numbering,
rather than the modern `\listtext`/`\listtable` mechanism. Two problems:
1. The `\pntext` marker text ("1.", "·", etc.) was captured as the
paragraph's first text run, which sits before the paragraph's
`\ls`/`\ilvl`, so emitBlocks (which reads list properties from the first
run) misclassified the paragraph as an ordinary paragraph. The first
item of each list therefore came out as a stray paragraph.
2. The numbering style was ignored, so numbered lists defaulted to
bullets.
Treat `\pntext` like `\listtext`: drop its visible marker text and flag the
start of a new list item. Parse the `{\*\pn ...}` destination
(`\pnlvlbody`/`\pnlvlblt`, `\pndec`, `\pnucltr`, `\pnlcltr`,
`\pnucrm`, `\pnlcrm`, `\pnstart`, and the `\ls`/`\ilvl` keys it
carries) into the list override table so numbered lists are
emitted as ordered lists with the right number style.
`\pn` is a paragraph property that remains in effect until reset
by `\pard`, auto-numbering every paragraph in scope. Track
this (`sPnActive`) so each paragraph becomes its own list item,
rather than merging markerless continuation paragraphs as is done
for modern `\listtext` lists.
Co-Authored-By: Claude <noreply@anthropic.com>
Lists were written as plain paragraphs with a literal marker and a
hanging indent, carrying none of the `\ls`/`\ilvl` references or the
`\listtable`/`\listoverridetable` that the RTF list model (and pandoc's
own reader) expect, so lists could not round-trip.
Walk the document tagging each list with a unique id and nesting level
(`prepareLists`), build a `\listtable`/`\listoverridetable` describing
each list (`listTableRTF`, exposed via the `listtable` template
variable), and render every list paragraph with its `\ls`/`\ilvl`
reference. The first paragraph of each item gets a `{\listtext}`
marker; continuation paragraphs keep the reference but omit it, so
multi-paragraph items round-trip.
Co-Authored-By: Claude <noreply@anthropic.com>
The reader treated every list paragraph as a new list item, so a list
item containing several paragraphs was split into one item per
paragraph. In the RTF list model a new item is marked by a
`{\listtext ...}` destination group; a list paragraph lacking one is a
continuation of the current item.
Track whether a `{\listtext}` group was seen (`sListText`) and, in
`emitBlocks`, append a continuation paragraph (no `\listtext`) to the
current item rather than starting a new one.
Adds a `list_multiparagraph` reader test.
Co-Authored-By: Claude <noreply@anthropic.com>
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.
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>
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.
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.