Skip to content

Commit 7824aee

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 3ad0c84 commit 7824aee

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
)
144144
copybutton_prompt_is_regexp = True
145145
copybutton_remove_prompts = True
146+
copybutton_line_continuation_character = "\\"
146147

147148
# sphinxext-rediraffe
148149
rediraffe_redirects = "redirects.txt"

0 commit comments

Comments
 (0)