Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Line breaking in a code span can break the block structure

Aperta
#323 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
c
Ambito
tooling

Direzione di ricerca

Riproduci i casi segnalati con i comandi cmark nell’issue, in particolare gli input dei code span sottoposti a rendering con --width 3. Leggi le regole proposte per le interruzioni di riga e confrontale con il comportamento di parsing e rendering di CommonMark. Il lavoro è completato quando le interruzioni di riga all’interno dei code span non modificano più le intestazioni, i paragrafi, i blocchi di codice delimitati o la struttura degli elenchi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

In CommonMark rendering, line breaking in a code span can break the block structure. Here are just a few examples:

$ printf '`xx --- xx`' | cmark -t commonmark --width 3 | cmark -t html
<h2>`xx</h2>
<p>xx`</p>
$ printf '`xx ``` xx`' | cmark -t commonmark --width 3 | cmark -t html
<p>`xx</p>
<pre><code>xx`
</code></pre>
$ printf '`xx + x xx`' | cmark -t commonmark --width 3 | cmark -t html
<p>`xx</p>
<ul>
<li>x
xx`</li>
</ul>

In case anyone wants to discuss, here is my attempt to specify how I think CommonMark rendering should work:

Line breaking is only implemented inside a paragraph, not inside a heading or an HTML block.

Except inside raw HTML (which I've not thought about), any group of consecutive whitespace characters will turn into a single space or a newline followed by the current line prefix.

Break each line at the last breakable space that doesn't make the line too long. So a line will be wider than the specified width only if it contains no breakable spaces.

In code spans a space is breakable if and only if the following group of non-space characters does not match any of the following Perl regular expressions:

/^[#*-=_]+$/      thematic break, heading
/^(```|~~~)/      fenced code block
/^[<>]/           HTML block, block quote
/^[*+-]$/         list item
/^[0-9]+[).]$/    list item

In textual content all spaces are breakable. A backslash is inserted for the following groups of characters:

/[*<[\\_`]/       escape, code, emphasis, links, images, raw HTML
/[&][#A-Za-z]/    entity or numeric character reference
/^[#*-=_]+$/      thematic break, heading
/^(```|~~~)/      fenced code block
/^[<>]/           HTML block, block quote
/^[*+-]$/         list item
/^[0-9]+[).]$/    list item

In these expressions, ^ means the start of a line (perhaps following a line prefix) and $ means space or the end of the line.

The backslash is inserted in front of each group, except in the last case, where it is inserted in front of the parenthesis or dot.

I've almost certainly forgotten something in there.

Lingua principale
C
Stelle
2k
Fork
698
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di commonmark/cmark

Tutte le issue di commonmark/cmark

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.