-
-
Notifications
You must be signed in to change notification settings - Fork 520
Description
Clear and concise description of the problem
It can very effectively optimize the copying results of code blocks copied from the article (without clicking the copy button).
Suggested solution
give the code tag a language-codeType class
Alternative
No response
Additional context
Here I provide a partial excerpt and translation of an article I wrote to describe the necessity of this requirement:
A discussion: Optimization for article copying and pasting
Let's discuss the code block first
Generally, code blocks provide a copy button, through which you can easily copy. But sometimes when we want to take notes, we tend to copy along with the article parts above and below the code blocks. However, different websites have different optimizations for this:
- CSDN, rubbish
- cnblog, perfect
- MdBook,rubbish
First, compare the second and the fourth points. Then I tried to track the differences between them. What kind of code affected the copied and pasted content? Is there additional js control or is it purely determined by the dom structure? After debugging, it was found to be the latter. Just add a class of language-xxxx to the code and it will be fine.
As long as a class is added, the annotation of the code block type during copying can be completed.
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.



