text-crossrefs: Avoid errors in Typst

This commit is contained in:
Bastien Dumont
2025-12-22 09:41:53 +01:00
parent 5cf18bd551
commit a5c484e3df
12 changed files with 21 additions and 14 deletions

View File

@ -209,6 +209,7 @@ You can control the placement via the attribute `refanchor`, which can be set to
When the value is `both`, _text-crossrefs_ creates two labels
by suffixing `-beg` and `-end` to the identifier.
The unsuffixed label remains usable except in Typst.
A typical use case is:
```

View File

@ -46,9 +46,7 @@ Here are some precisions.[^2]
* What if the note contains multiple spans with identifiers? → See [which-identifier]{.tcrf reftype="page"}.
* What happens if a span is contained in a span? → See [nested-spans]{.tcrf reftype="page"}.
* What are the notes? → [my-evaluation ; format ; refer-to-note]{.tcrf}
* Where are the notes? → [my-evaluation;format]{.tcrf reftype="page"}
[]{#toc-notes-end}
* Where are the notes? → [my-evaluation;format]{.tcrf reftype="page"}[]{#toc-notes-end}
[A portion of text that may cross a page break.]{#doubledlbl refanchor=both}

View File

@ -30,9 +30,7 @@ Here are some precisions.[^2]
* What if the note contains multiple spans with identifiers? → See [which-identifier]{.tcrf}.
* What happens if a span is contained in a span? → See [nested-spans]{.tcrf}.
* What are the notes? → [my-evaluation, format, refer-to-note]{.tcrf reftype=note}
* Where are the notes? → [my-evaluation,format]{.tcrf}
[]{#toc-notes-end}
* Where are the notes? → [my-evaluation,format]{.tcrf}[]{#toc-notes-end}
[A portion of text that may cross a page break.]{#doubledlbl refanchor=both}

View File

@ -388,10 +388,11 @@
(Format "context")
"\\crossrefenum[page]{my-evaluation, format}"
]
, Str ""
, Span ( "toc-notes-end" , [] , [] ) []
]
]
]
, Para [ Str "" , Span ( "toc-notes-end" , [] , [] ) [] ]
, Para
[ Str ""
, Span

View File

@ -382,10 +382,11 @@
(Format "context")
"\\crossrefenum{my-evaluation, format}"
]
, Str ""
, Span ( "toc-notes-end" , [] , [] ) []
]
]
]
, Para [ Str "" , Span ( "toc-notes-end" , [] , [] ) [] ]
, Para
[ Str ""
, Span

View File

@ -385,10 +385,11 @@
(Format "latex")
"\\crossrefenum[page]{my-evaluation, format}"
]
, Str ""
, Span ( "toc-notes-end" , [] , [] ) []
]
]
]
, Para [ Str "" , Span ( "toc-notes-end" , [] , [] ) [] ]
, Para
[ Str ""
, Span

View File

@ -379,10 +379,11 @@
(Format "latex")
"\\crossrefenum{my-evaluation, format}"
]
, Str ""
, Span ( "toc-notes-end" , [] , [] ) []
]
]
]
, Para [ Str "" , Span ( "toc-notes-end" , [] , [] ) [] ]
, Para
[ Str ""
, Span

View File

@ -390,10 +390,11 @@
(Format "opendocument")
"pages\160<text:bookmark-ref text:reference-format=\"page\" text:ref-name=\"my-evaluation\">000</text:bookmark-ref>; and <text:bookmark-ref text:reference-format=\"page\" text:ref-name=\"format\">000</text:bookmark-ref>"
]
, Str ""
, Span ( "toc-notes-end" , [] , [] ) []
]
]
]
, Para [ Str "" , Span ( "toc-notes-end" , [] , [] ) [] ]
, Para
[ Str ""
, Span

View File

@ -390,10 +390,11 @@
(Format "opendocument")
"pp.\160<text:bookmark-ref text:reference-format=\"page\" text:ref-name=\"my-evaluation\">000</text:bookmark-ref> and <text:bookmark-ref text:reference-format=\"page\" text:ref-name=\"format\">000</text:bookmark-ref>"
]
, Str ""
, Span ( "toc-notes-end" , [] , [] ) []
]
]
]
, Para [ Str "" , Span ( "toc-notes-end" , [] , [] ) [] ]
, Para
[ Str ""
, Span

View File

@ -390,10 +390,11 @@
(Format "typst")
"pages\160#ref(form: \"page\", <my-evaluation>); and #ref(form: \"page\", <format>)"
]
, Str ""
, Span ( "toc-notes-end" , [] , [] ) []
]
]
]
, Para [ Str "" , Span ( "toc-notes-end" , [] , [] ) [] ]
, Para
[ Str ""
, Span

View File

@ -389,10 +389,11 @@
(Format "typst")
"pp.\160#ref(form: \"page\", <my-evaluation>) and #ref(form: \"page\", <format>)"
]
, Str ""
, Span ( "toc-notes-end" , [] , [] ) []
]
]
]
, Para [ Str "" , Span ( "toc-notes-end" , [] , [] ) [] ]
, Para
[ Str ""
, Span

View File

@ -236,6 +236,8 @@ local function control_label_placement(span)
elseif label_placement == 'both' then
span.content:insert(1, pandoc.Span({}, { id = id .. '-beg' })) -- for DOCX/ODT
span.content:insert(pandoc.Span({}, { id = id .. '-end' }))
-- Typst does not allow multiple labels on the same content.
if FORMAT== 'typst' then span.identifier = '' end
else
warning('Invalid value ' .. label_placement .. ' on attribute ' .. PLACE_LABEL_ATTR .. ': ' ..
'shoud be “beg”, “end” or “both”. Falling back to Pandocs default.')