Skip to content

Long inline <code> snippets within lists do not wrap (HTML documents) #13258

@glin

Description

@glin

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

This is similar to these old issues about inline <code> not wrapping: #2649, #3221

Those two issues are fixed, but there seems to be another edge case with inline <code> not wrapping if it's inside a list. Outside of lists, <code> gets white-space: pre-wrap styling that wraps the text. Within lists, <code> gets white-space: pre styling that does not wrap.

We found this CSS that sets pre-wrap on code only if code is inside a <p>, which doesn't happen for code within lists.

// Inline code should wrap
// See https://github.com/quarto-dev/quarto-cli/issues/2649
dd code:not(.sourceCode),
p code:not(.sourceCode) {
white-space: pre-wrap;
}

It's a really minor issue, but I think you could hit this in some common cases. We discovered it in the Posit Package Manager release notes, where we have lists of changes that occasionally contain long inline error messages wrapped in code. The release notes have a sidebar that limit the width of the content, so we had a few occurrences of this.

We also worked around it by separating each list item with a newline, which gets each list item wrapped in a <p>. But this is somewhat of an awkward workaround.

Steps to reproduce

Repro doc:

---
title: "Test for text wrapping of long inline `<code>` snippets in lists"
---

## Unordered list

Unordered list. `<code>` within lists gets `white-space: pre` styling which does not wrap.

- `Code 1`
- `Code 2`
- `This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet.`
- Item 4


## Unordered list with line breaks (workaround)

Unordered list with line breaks. Each item gets wrapped in `<p>` which matches the `white-space: pre-wrap` CSS. This works around the issue, but the extra space between list items can be awkward.

- `Code 1`

- `Code 2`

- `This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet.`

- Item 4

## Ordered list

Ordered list:

1. `Code 1`
2. `Code 2`
3. `This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet.`
4. Item 

## Inline code by itself

Outside of lists, this gets wrapped in `<p>` so it gets the `white-space: pre-wrap` CSS.

`This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet. This is a really long inline code snippet.`
rendered output of the doc

Actual behavior

The inline code items do not wrap in the Unordered list and Ordered list cases.

Expected behavior

The inline code items wrap in the Unordered list and Ordered list cases.

Your environment

  • Positron 2025.08.0
  • Windows 11

Quarto check output

Quarto 1.8.21
[>] Checking environment information...
      Quarto cache location: C:\Users\greg\AppData\Local\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.21
      Path: C:\Users\greg\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[>] Checking LaTeX....................OK
      Tex:  (not detected)

[>] Checking Chrome Headless....................OK
      Using: Chrome found on system
      Path: C:\Program Files\Google\Chrome\Application\chrome.exe
      Source: Windows Registry

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.13.3
      Path: C:/Users/greg/AppData/Local/Programs/Python/Python313/python.exe
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python -m pip install jupyter

[>] Checking R installation...........OK
      Version: 4.5.1
      Path: C:/PROGRA~1/R/R-45~1.1
      LibPaths:
        - C:/Users/greg/AppData/Local/R/win-library/4.5
        - C:/Program Files/R/R-4.5.1/library
      knitr: 1.50
      rmarkdown: 2.29

[>] Checking Knitr engine render......OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingthemesRelated to HTML theming or any other style related issue (like highlight-style)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions