Code span inside link text drops the backslash or ends the link early (\], \[, backtick)

Abierto
#4,176 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

@hakarrr ya está trabajando en esto.

Desde el 9/11/2026.

  • #1 de @young1lin — cerrado sin fusionar
  • #83 de @lockfile-maintenance — fusionado
  • #4180 de @young1lin — cerrado sin fusionar
  • #4209 de @hakarrr — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript
Área
tooling

Línea de trabajo

Start by running the three inputs in the issue through new Marked().parse(input) and comparing them with the expected <a> and <code> output. The payload names no source files, so locate the inline rules that handle code spans and link brackets, and check which one wins when a code span sits inside link text. Done when all three cases match the CommonMark output, with backslashes kept literal inside <code> and the second link in case 3 parsed separately.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

category: inline elements L2 - annoying

Marked version: 18.1.2

Describe the bug

A code span inside link text loses its literal backslash, or ends the link early, when its content contains a backslash, a square bracket or a backtick. In CommonMark, code span content is literal (no backslash escapes), and code spans bind more tightly than link brackets.

To Reproduce

Unmodified new Marked().parse(input); the trailing newline is omitted from the output.

1. Input:    [`\]`](https://x.test/)
   Expected: <p><a href="https://x.test/"><code>\]</code></a></p>
   Actual:   <p><a href="https://x.test/"><code>]</code></a></p>

2. Input:    [`\[`](https://x.test/)
   Expected: <p><a href="https://x.test/"><code>\[</code></a></p>
   Actual:   <p><a href="https://x.test/"><code>[</code></a></p>

3. Input:    [`` ` ``](https://x.test/)[\`](https://x.test/)
   Expected: <p><a href="https://x.test/"><code>`</code></a><a href="https://x.test/">`</a></p>
   Actual:   <p><a href="https://x.test/"><code>`</code>](https://x.test/)[`</a></p>

Expected behavior

Matches the CommonMark reference implementation: the code span's content stays literal inside link text, and the second link in case 3 is parsed separately.

Found with a property test over generated Markdown. The class is narrow: a code span inside link text whose content has a backtick, backslash or square bracket. Happy to test a fix.

Lenguaje dominante
TypeScript
Estrellas
37.3k
Forks
3.9k
Merge medio
5 d 6 h
PR fusionados (30 d)
62

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de markedjs/marked

Todos los issues de markedjs/marked

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.