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>
This commit is contained in:
John MacFarlane
2026-06-13 21:26:54 +00:00
parent 853ae7fecc
commit ec4fb91049
5 changed files with 71 additions and 7 deletions
+37
View File
@@ -0,0 +1,37 @@
With `auto_identifiers` enabled, headings without an explicit label get
automatic identifiers, with collisions disambiguated:
```
% pandoc -f typst+auto_identifiers -t native
= Introduction
Text.
== A Sub Section
= Introduction
^D
[ Header
1 ( "introduction" , [] , [] ) [ Str "Introduction" ]
, Para [ Str "Text." ]
, Header
2
( "a-sub-section" , [] , [] )
[ Str "A" , Space , Str "Sub" , Space , Str "Section" ]
, Header
1 ( "introduction-1" , [] , [] ) [ Str "Introduction" ]
]
```
The extension is off by default, so headings have no identifiers:
```
% pandoc -f typst -t native
= Introduction
Text.
^D
[ Header 1 ( "" , [] , [] ) [ Str "Introduction" ]
, Para [ Str "Text." ]
]
```