akiomik / akiomik/mado

MD038: judge the multi-line code spans whose literal alone proves padding

Abierto
#404 0 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Rust
Estrellas
407
Forks
12
Merge medio
5 h 45 min
PR fusionados (30 d)
30

Descripción

#402 stopped MD038 from judging a code span whose delimiters sit on different
lines. Nothing recorded about such a span describes what was written against its
delimiters: `literal` has already turned the line endings into spaces and taken
the padding off, a width cannot be had from columns that index two different
lines, and reading the lines back fails four ways that #402 documents. Skipping
is right for those four shapes, but it also gives up on a subset that `literal`
alone can still prove.

## The subset

A line ending contributes exactly one space to `literal`. So whitespace deeper
than one byte at either end cannot have come from a line ending, and has to be
in the source.

```markdown
`a
b `
```

comrak gives `literal = "a b "`. Two trailing spaces, one of which is at most
the line ending, so at least one was written. Same the other way:

```markdown
` a
b`
```

gives `literal = " a b"`. mado reported both of these before #402 and passes
them silently now.

## The guard has to be the two-space one

A `trim()`-style test is **not** safe here:

```markdown
> `text
>`
```

gives `literal = "text "`, and that single trailing space is the line ending in
its entirety — there is no padding in the source at all. Reporting it would be
exactly the kind of violation an author cannot act on that #402 was about.

"Two or more spaces at an end" is the version that holds, because the line
ending can only ever account for one of them.

## What is left open

- Whether one space of padding either side of a line ending — the case this
guard cannot separate from the line ending itself — is worth any further
effort, or whether the two-space subset is where this should stop.
- Tabs. `literal` keeps a tab as a tab, and a line ending never becomes one, so
a leading or trailing tab is provably from the source even on its own. Whether
MD038 should treat a tab as padding is a separate question from whether it can
see it.
- Where the violation should be reported. The columns of a multi-line span are
not reliable (#403 is a related shift), and the two ends of one belong to
different lines.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.