spring-io / antora-ui-spring

Mozilla Public License 2.0
13 stars 26 forks source link

Automatically strip leading $ characters when copying content of a source block that is using the console language #252

Open wilkinsona opened 1 month ago

wilkinsona commented 1 month ago

By convention, much of the Spring portfolio's documentation uses a $ prefix for source blocks containing shell commands. This prefix is also mentioned in Asciidoctor's own documentation:

Typically, the syntax highlighter will parse the prompt (e.g., $) at the start of each line, then handle the remaining text using the shell language.

When copying the content of a console source block, it would be great if any leading $ characters could be removed automatically. This would allow users to paste the command(s) into their terminal and run them without alteration.

philwebb commented 1 month ago

https://docs.asciidoctor.org/asciidoctor/latest/extensions/tree-processor/ and https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/main/lib/shell-session-treeprocessor/extension.rb might be useful here.