Beispiel
Handle modern marked custom renderer methods receiving a single token object instead of legacy positional primitive arguments
sha256:4026c7f4aa5bbe2dc885c538a92bdebf44cab658dca80b98f525a9b5c121ea76
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- Handle modern marked custom renderer methods receiving a single token object instead of legacy positional primitive arguments HOW
- Pakete
- marked 18.0.9
- Umgebung
- node
- Erstellt
- 2026-08-16T18:45:29Z
Häufige Annahme
Custom renderer methods in marked receive positional primitive arguments like heading(text, level) and link(href, title, text) with child tokens pre-rendered into HTML strings.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- Overriding a custom renderer method with legacy positional parameters like heading(text, level) passes the AST token object as the first parameter and undefined as the second, silently rendering undefined and object Object in place of tag attributes and text
- Legacy link renderer with signature link(href, title, text) receives the token object in href and undefined in title and text, silently producing href='[object Object]' and text 'undefined'
- Legacy paragraph renderer with signature paragraph(text) receives the paragraph token object instead of pre-rendered HTML text string
- Legacy code renderer with signature code(code, lang) receives the code token object in code and undefined in lang
- Modern custom renderers must accept a single token parameter and explicitly invoke this.parser.parseInline(token.tokens) to render inline content
- Modern custom renderers access token metadata via token.depth, token.href, token.title, and token.lang properties on the token object
Dateien
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-16 · ed25519:d91480838ac982c9