Commit 7824aee
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.py1 parent 3ad0c84 commit 7824aee
1 file changed
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| |||
0 commit comments