Replies: 2 comments 1 reply
-
Thanks for suggesting. Definitely an interesting idea, but this requires that you can cut your code block into ranges. We wouldn't need support in SuperFences, because copying is entirely implemented in the browser with JavaScript, so it's likely a better idea to just implement this in the frontend. Let's let that sit here for a while and see what others think. Related |
Beta Was this translation helpful? Give feedback.
1 reply
-
Just had another question in this regard, specifically about Python and the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @squidfunk, all,
In technical documentation, where mkdocs-material particularly shines, code blocks are first-class citizens.
While we already have a mighty code block support in mkdocs-material thanks to @facelessuser SuperFences, I still miss a couple of features, of which allowing users to define which lines to copy by default is the topic of this idea.
In a code block like this
it is impossible to copy out the command itself using the copy icon as it stands right now. The copy button selects the whole code block entirely and this hurts UX, since a lot of tech docs are meant to provide a user with a copy-pastable command instructions and output is always useful to display but rarely to copy.
It would be great to have an attribute for user-defined copy range to solve this.
Today, I solve this with two code blocks, one is the code block with a command, and the other is with the result.
The block with the result I wrap in a special div element with the class that uses margins to glue the two blocks together.
But it is a lot to type and feels more like a hack, compared to a custom attr that can be used for this with a syntax like:
The
copy-range
syntax followslinenums
syntax used in SuperFences, but can even be enhanced to allow to select chars to start/end copy range.For example, if the code block has a prompt
$
char we can allow a user to start the copy range without it:where
copy-range="1:2"
means copy line number 1, but after the first two chars, which is a$
substring.Beta Was this translation helpful? Give feedback.
All reactions