Skip to content

Commit 86c0bc1

Browse files
committed
docs(fix[copybutton]): Enable line continuation for multiline console blocks
why: sphinx-copybutton's copy button silently drops continuation lines in multiline `\`-continued console commands. For example, clicking copy on: ```console $ pipx install \ --suffix=@next \ --pip-args '\--pre' \ --force \ 'libtmux' ``` Only copies `pipx install \` — the continuation lines are discarded. Root cause: `copybutton_line_continuation_character` defaults to `""`. In copybutton_funcs.js, `useLineCont = !!""` evaluates to `false`, so `gotLineCont` never activates. Lines not matching the prompt regex (`$ `) are silently dropped by the formatCopyText() line-processing loop. Setting it to `"\\"` makes `useLineCont = true`, and any line ending in `\` sets `gotLineCont = true` for the next iteration, including it regardless of prompt match. This is the standard fix adopted by Apache Arrow, NVIDIA TensorRT-LLM, Flower, Crate docs theme, and Nextstrain sphinx theme. Refs: - https://sphinx-copybutton.readthedocs.io/en/latest/use.html - executablebooks/sphinx-copybutton#126 - executablebooks/sphinx-copybutton#65 - executablebooks/sphinx-copybutton#52 what: - Add `copybutton_line_continuation_character = "\\"` to docs/conf.py
1 parent cbb1552 commit 86c0bc1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
)
133133
copybutton_prompt_is_regexp = True
134134
copybutton_remove_prompts = True
135+
copybutton_line_continuation_character = "\\"
135136

136137
# sphinxext-rediraffe
137138
rediraffe_redirects = "redirects.txt"

0 commit comments

Comments
 (0)