-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
data-copy
for code blocks actually supports newlines
#6177
Comments
Thanks for noting. However, encoding newlines as HTML entities is not something that we want to advertise on our documentation, as we need to keep it simple and concise. Please don't forget that many users are non-technical. Otherwise users will keep opening issues, asking how to achieve this, making more work for us with no upside for the project. It's great that it's documented here now, but this feature is definitely something for advanced users. Note that it's also tagged as experimental, so if it turns out that it increases maintenance overhead for us, we might remove it again. |
In fact, the braces problem almost leads me to the decision to remove it again. I did not know that. It seems just so impractical to use. Could I ask you to open an issue over at Python Markdown, to ask whether we could lift the restrictions on HTML entities? If regular verbatim code could be included, that would make up for much better usability. |
What if the value to copy was in a separate code block? Consider this example:
Any code block with the class |
That is indeed an interesting approach. |
Just one small comment, @waylan. IDs ( |
Interesting idea, definitely, but it's significantly more complicated from a theme developer's perspective. Nonetheless, it might be a much better idea than having to escape to HTML entities. |
@iBug I agree, IDs would make more sense. |
FYI, we removed this feature from our documentation. The current implementation is too fragile and will likely lead to many problems when being used by non-technical users. We don't feel comfortable providing support for it at the current stage. |
With Python-Markdown/markdown#1414 being merged, the curly braces issue has been fixed. Other characters that has to be HTML-encoded still remains. |
Description
This part of the documentation is misleading and missing information:
In fact, as long as new lines are HTML-encoded (i.e.
), they stay perfectly intact when copied.Additionally, if the value to
data-copy
contains braces, they must be HTML-encoded as well (i.e.{
and}
), or the Markdown parser breaks on that code block (which I actually suspect to be a bug - they're already inside double quotes).It would be nice if these tips and quirks are noted in the documentation.
Basic reproduction:
Related links
Reporting a docs issueProposed change
Remove the offending sentence and add the following text after the original paragraph and example:
I couldn't work out a satisfactory replacement by myself, so this is just a suggestion. A better example is certainly welcome.
Before submitting
The text was updated successfully, but these errors were encountered: