HTML export panics on multi-byte character after `</` in raw text element
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 56.1k
- Forks
- 1.7k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 22
Description
Description
Description
HTML export panics with a char-boundary error when a raw text element (style, script, etc.) contains </ followed by a multi byte character within "tag name length" distance.
Minimal reproduction (typst compile --features html repro.typ repro.html):
#html.elem("style", "</abcd−")
(note the last character is U+2212 MINUS SIGN)
Sorry, can't upload a .typ file, thanks Github!
I get:
thread 'main' panicked at crates/typst-html/src/encode.rs:297:20:
byte index 5 is not a char boundary; it is inside '−' (bytes 4..7) of `abcd−`
The text that triggered this originally is in Typst's standard library documentation for the cbor module: crates/typst-library/src/loading/cbor.rs, line 65, see here. This was observed via tinymist's package doc generator.
Claude patched a local checkout of the typst-html crate, but per CONTRIBUTING.md's policy on AI-implemented contributions I'm only reporting it as an issue rather than opening a PR with Claude's one-line fix.
Operating system: macOS
Typst version: 0.15.1
Operating system
macOS
Typst version
- I am using the latest version of Typst
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimal reproduction with the HTML feature, then inspect crates/typst-html/src/encode.rs around line 297 where the char-boundary panic occurs. Compare the raw text example with the triggering text in crates/typst-library/src/loading/cbor.rs around line 65. Done means HTML export completes without panicking when a multi-byte character follows the raw-text terminator prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100