Skip to content

Invalid String length on embedded notebook #12853

@albertomercurio

Description

@albertomercurio

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

When I embed a notebook with some matplotlib figures, and labels in LaTeX, I get the error

ERROR: RangeError: Invalid string length

Stack trace:
    at String.replaceAll (<anonymous>)
    at replaceNotebookPlaceholders (file:///Applications/quarto/bin/quarto.js:79067:33)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async renderPandoc (file:///Applications/quarto/bin/quarto.js:79445:28)
    at async Object.onRender (file:///Applications/quarto/bin/quarto.js:87135:36)
    at async renderFileInternal (file:///Applications/quarto/bin/quarto.js:87112:17)
    at async renderFiles (file:///Applications/quarto/bin/quarto.js:86936:17)
    at async render (file:///Applications/quarto/bin/quarto.js:91850:21)
    at async Command.actionHandler (file:///Applications/quarto/bin/quarto.js:92001:32)
    at async Command.execute (file:///Applications/quarto/bin/quarto.js:8253:13)

I found that the problem comes from these lines

ax.set_xlabel('Position $x$')
ax.set_ylabel('Momentum $p_x$')

Indeed, if I replace them with

ax.set_xlabel("Position $x$")
ax.set_ylabel("Momentum $p_x$")

It works. However, it is not clear why it fails if using the first case.

Steps to reproduce

Just clone the following repository

On the string-length branch.

Actual behavior

Returns the error

Expected behavior

No errors during rendering

Your environment

MacOS Sequoia

Quarto check output

Quarto 1.7.31
[✓] Checking environment information...
      Quarto cache location: /Users/alberto/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.6.3: OK
      Dart Sass version 1.85.1: OK
      Deno version 1.46.3: OK
      Typst version 0.13.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.7.31
      Path: /Applications/quarto/bin

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

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /Library/TeX/texbin
      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.12.9 (Conda)
      Path: /opt/homebrew/Caskroom/miniconda/base/envs/comp-quantum-optics/bin/python
      Jupyter: 5.7.2
      Kernels: julia-1.11, julia-1.10, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingembed

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions