Commit 86c0bc1
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 cbb1552 commit 86c0bc1
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
0 commit comments