mdBook icon indicating copy to clipboard operation
mdBook copied to clipboard

Provide a mechanism for ignoring leading characters in a code block

Open sdball opened this issue 6 years ago • 2 comments

This is coming from https://github.com/rust-lang/book/issues/1756

It'd be great for mdbook to provide some kind of mechanism to declare leading characters that should be ignored by the "copy to clipboard" button. Specifically in the Rust Book's case: to omit the leading $ characters from being copied to the clipboard. That will allow readers to paste commands into their terminal without having to manually edit the command.

sdball avatar Jan 09 '19 01:01 sdball

Nodebook interactive tutorial book has done in with CSS and a simple regex https://github.com/oncletom/nodebook/blob/master/src/asciidoctor-extension-bash-dollar.js

Do you think it's a suitable way to achieve the same in mbBook?

ojn avatar Jan 24 '19 12:01 ojn

Hi @ehuss , I am happy to take this on and send a PR. Would you be open to reviewing it?

sreeram-arista avatar Mar 22 '24 18:03 sreeram-arista