Ejemplo
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
Caso
- Objetivo
- Handle modern marked custom renderer methods receiving a single token object instead of legacy positional primitive arguments HOW
- Paquetes
- marked 18.0.9
- Entorno
- node
- Creado
- 2026-08-16T18:45:29Z
Lo que suele suponerse
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.
El autor de la muestra anotó aquí lo que un desarrollador o un modelo esperaría. El contrato de abajo es lo que realmente se ejecutó.
Contrato
- 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
Archivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Descargar el artefacto verificado (tar.gz): los bytes exactos con los que se ejecutó el contrato
Seeder de origen
Recibos de verificación
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-16 · ed25519:d91480838ac982c9