Setext Heading LRDs take precedence over Paragraph LRDs
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- compilers
Línea de trabajo
Reproduce los dos ejemplos e inspecciona Parser.refmap, inline.js y el paso de finalización del documento para rastrear cuándo se registran los LRD de Setext y de párrafo. Verifica cómo se puede aplicar el orden propuesto sin romper las mutaciones de inline.js. Se considera terminado cuando las etiquetas duplicadas se resuelven sistemáticamente al primer LRD según el orden del documento, incluidos los casos de encabezados Setext.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The only reference to precedence I could find in the spec is this:
If there are multiple matching reference link definitions, the one that comes first in the document is used. (It is desirable in such cases to emit a warning.)
The issue is that when you define a LRD (link reference definition) in a Setext heading (or a probable Setext heading*), this link will populate the refmap before any paragraph LRDs are parsed, which occurs at the document finalization step.
*A paragraph interrupted by a setext heading underline that only contains links, thus creating an empty <p>, which is immediately unlinked from the AST.
Example inputs:
[x]: fizz
[x]: buzz
===
[x]
has an href=buzz,
Whereas
[x]: fizz
[x]: buzz
[x]
has an href=fizz.
My interpretation of the spec is that both should result in href=fizz as that is the first LRD.
Assuming this is a bug, my idea of a fix would be to use a modified Parser.refmap where it has an Map<number, Array<LRD>> and the key would be the line number of the containing paragraph (sourcepos[0][0]), as the exact lines don't matter as long as the array is populated in-order.
So if this was the input
[line1]: a
[line2]: b
rest of paragraph
[line5]: e
===
would have the map
{
5: [e],
1: [a, b]
}
(where a, b, e are objects of typedef LRD {destination: string, title: string, label: string} with map def
Map<number, Array<LRD>>)
Then setext headings' block start and document finalization can occur in the order they do, but could add another step after document finalization. E.g.
/**
* @param {Map<number, Array<{destination: string, title: string, label: string}>>} unorderedRefmap
*/
function getFinalRefmap(unorderedRefmap) {
const sortedKeys = [...unorderedRefmap.keys()].sort((a, b) => a - b);
const finalRefmap = {};
for (const k of sortedKeys) {
const values = unorderedRefmap.get(k);
for (const v of values) {
if (!finalRefmap[v.label]) {
finalRefmap[v.label] = {destination: v.destination, title: v.title};
}
}
}
return finalRefmap ;
}
Something like that should work, its just a matter of adding to the placeholder refmap correctly, which is a bit trickier since inline.js needs a reference to it and mutates it.
- Lenguaje dominante
- JavaScript
- Estrellas
- 1.6k
- Forks
- 231
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de commonmark/commonmark.js
-
White space handling looks inconsistent between HTML block element vs HTML inline elementPosiblemente ocupada @mamicicekel la tomó hace 3 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
commonmark/commonmark.js#303 · 2 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
commonmark/commonmark.js#287 · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 20/100
commonmark/commonmark.js#275 ·
-
Delegate node walking to othersAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
commonmark/commonmark.js#267 · 3 comentarios ·
-
Inconsistent escape of image altAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
commonmark/commonmark.js#264 · 1 reacción ·
Todos los issues de commonmark/commonmark.js
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NaturalIntelligence/fast-xml-parser#888 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
bug callouts regression revealjs
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
quarto-dev/quarto-cli#15014 ·
Los mantenedores suelen responder en 1 día
-
Remove: Fox Deportes SDAbiertocheck:passed feeds:remove
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
iptv-org/database#37176 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 9 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
hawk-digital-environments/HAWKI#443 ·
Los mantenedores suelen responder en 1 día
-
documentation v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
modelcontextprotocol/python-sdk#3662 ·
Los mantenedores suelen responder en 1 día