Duplicated newlines in ansi-escaped-output
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
Start with the self-contained Quarto example in the linked quarto-ansi repository and render it with the Jupyter engine to reproduce the duplicated newlines in the HTML ansi-escaped-output block. Trace the rendering path for that output and add regression coverage using the example; done means newline_para and carriage_para render with single line breaks.
Written by the indexing model from the issue text.
Description
I have:
- searched the issue tracker for similar issues
- installed the latest version of Quarto CLI
- formatted my issue following the Bug Reports guide
Bug description
I'm reformatting strings with ansi codes to illustrate RegEx matches using the jupyter engine. When printing these strings, newlines are, for some reason, doubled in html output. If I replace the newlines with carriage returns, the carriage returns aren't doubled.
This is with quarto v1.8.27
The most relevant pre-existing issues I found here were #12132 and #12966, but neither mentioned issues with newlines
Steps to reproduce
Here's a qmd that will reproduce the issue. I've also got a github repo including the self-contained rendered html. https://github.com/JoFrhwld/quarto-ansi
````qmd
---
title: "Quarto Ansi"
format:
html:
self-contained: true
engine: jupyter
---
```{python}
import re
```
```{python}
paragraph = """This is a paragraph.
This paragraph has multiple lines.
This paragraph has just one new line between each line."""
```
```{python}
print(paragraph)
```
```{python}
newline_para = re.sub(
r"( para)",
r'\033[31;1;4m' + r'\1' + r'\033[0m',
paragraph
)
carriage_para = re.sub(
r"\n",
r"\r",
newline_para
)
```
```{python}
print(newline_para)
```
```{python}
print(carriage_para)
```
````
Actual behavior
From the rendered html, the result of printing newline_para is
<div class="cell-output cell-output-stdout">
<div class="ansi-escaped-output">
<pre>This is a<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph.
This<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph has multiple lines.
This<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph has just one new line between each line.
</pre>
</div>
</div>
While the result of printing carriage_para is
<div class="cell-output cell-output-stdout">
<div class="ansi-escaped-output">
<pre>This is a<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph.
This<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph has multiple lines.
This<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph has just one new line between each line.
</pre>
</div>
</div>
Expected behavior
I expected the rendered output for both would be
<div class="cell-output cell-output-stdout">
<div class="ansi-escaped-output">
<pre>This is a<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph.
This<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph has multiple lines.
This<span style="font-weight:bold;text-decoration:underline" class="ansi-red-fg"> para</span>graph has just one new line between each line.
</pre>
</div>
</div>
Your environment
- IDE: Visual Studio Code v1.108.2, Positron v2026.01.0
- Python: 3.13
- OS: macOS Tahoe 26.2
Quarto check output
[✓] Checking environment information...
Quarto cache location: /Users/joseffruehwald/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.6.3: OK
Dart Sass version 1.87.0: OK
Deno version 2.3.1: OK
Typst version 0.13.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.8.27
Path: /Applications/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (external install)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/joseffruehwald/Library/TinyTeX/bin/universal-darwin
Version: 2025
[✓] Checking Chrome Headless....................OK
Using: Chrome found on system
Path: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Source: MacOS known location
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.13.5
Path: /Users/joseffruehwald/Documents/misc/quarto-ansi/.venv/bin/python3
Jupyter: 5.9.1
Kernels: python3, ir
[✓] Checking Jupyter engine render....OK
[✓] Checking R installation...........OK
Version: 4.5.0
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
knitr: 1.51
rmarkdown: 2.30
[✓] Checking Knitr engine render......OK
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from quarto-dev/quarto-cli
-
binder bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
quarto-dev/quarto-cli#14907 · 3 comments ·
-
brand bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
quarto-dev/quarto-cli#14891 ·
-
brand bug html revealjs
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
quarto-dev/quarto-cli#14882 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
quarto-dev/quarto-cli#14875 ·
-
Percent scripts: accept raw-string (r""") and '''-delimited markdown cells, as jupytext writes them Openengines-jupyter enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
quarto-dev/quarto-cli#14850 · 2 comments ·
All issues in quarto-dev/quarto-cli
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
babalae/bettergi-scripts-list#3674 ·
-
ecosystem wording
Difficulty 1/5 Under an hour Newbie friendliness 90/100
matrix-org/matrix.org#3649 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vadimdemedes/ink#1029 ·
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·