Incremental writer emits LF for a rewritten block or separator in a CRLF document
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 78/100
Direzione di ricerca
Start in crates/pampa/src/writers/incremental.rs, especially write_block_to_string and compute_separator; compare their freshly generated text with copied text on a CRLF input. The issue gives a reproduction shape and a suggested approach: detect the original document’s line endings and preserve them for rewritten blocks and synthesized separators. Done when the output keeps CRLF throughout after a block rewrite, while existing inline splicing still works.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Reproduction
At tag v0.37.0 (and on main at a37801fe4), on a CRLF (\r\n) document, make an edit that forces the incremental writer to rewrite a block from scratch rather than copy or splice it (for example, appending a brand-new paragraph with no original counterpart, or editing a paragraph in a way the inline-splice safety check rejects). Compute quarto_ast_reconcile::compute_reconciliation(&original, &edited) and call pampa::writers::incremental::incremental_write.
Minimal shape:
First paragraph.\r\n\r\nLast paragraph.\r\n
(all \r\n). After an edit that forces a block-level rewrite, the rewritten block and the separator immediately around it come out with \n instead of \r\n, while the rest of the file keeps \r\n.
A simpler case — editing a word in place inside a CRLF paragraph, where the result is handled by inline splicing rather than a full block rewrite — keeps \r\n correctly, because splicing copies bytes from the original rather than writing fresh text.
Observed vs expected
Observed: a rewritten block, and the separators the incremental writer has to synthesize around it (rather than copy from the original gap), use bare \n, producing a document with mixed line endings.
Expected: a rewritten block and its separators use the same line-ending convention as the rest of the document.
Cause
The standard QMD writer (crates/pampa/src/writers/qmd.rs) always emits bare \n — reasonably so, since most callers want platform-independent output. The incremental writer calls that standard writer whenever it has to rewrite a block from scratch (write_block_to_string in crates/pampa/src/writers/incremental.rs), and falls back to a literal "\n" separator in compute_separator whenever it can't copy the original gap verbatim (one of the two adjacent entries is a rewrite). Neither function looks at the original document's line-ending convention.
Suggested fix
Detect the document's line-ending convention once from original_qmd (e.g. "does it contain \r\n"), and when a block must be rewritten or a separator must be synthesized, convert/emit \r\n instead of \n in that case. The standard writer itself does not need to change — only the incremental writer's own freshly-generated text.
- Lingua principale
- Rust
- Stelle
- 302
- Fork
- 22
- Merge medio
- 5h 8m
- PR unite (30g)
- 220
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di quarto-dev/q2
-
`q2 render` ignores `NO_COLOR` and prints colour codes and hyperlinks in its diagnosticsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
quarto-dev/q2#1135 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
quarto-dev/q2#1133 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
quarto-dev/q2#1103 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
quarto-dev/q2#1095 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
quarto-dev/q2#1031 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di quarto-dev/q2
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
area:cli kind:docs prio:low
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
DecapodLabs/decapod#1626 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno