-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
[V2] Potential code block improvements #2271
Comments
Sounds very useful indeed! |
I've built these features out for an internal site on docusaurus v1 before. I'll take a stab at implementing it with this syntax sometime next week if no one takes it before then. |
It looks life @kohheepeace has the code titles figured out. I can take a stab at the code highlight comments. |
Looks like the filename title PR is almost done. @elviswolcott , are you still looking at doing the code highlighting comments feature? |
Yeah, lost track of this with everything going on the last few weeks. I'll get a PR together in the next few days. |
My PR implements The linked Gatsby plugin also includes a If anyone thinks it should be added, I can throw it in. |
Looks like both the requested features are in https://github.com/facebook/docusaurus/releases/tag/v2.0.0-alpha.49 , so I'll close this. Thanks! |
Thank you @kohheepeace and @elviswolcott! |
🚀 Feature
v2 code blocks currently have the ability to highlight specific line numbers, like this:
However, highlighting lines based on line numbers is somewhat difficult to use.
The
gatsby-remark-prismjs
plugin has the ability to highlight individual lines by putting a// highlight-next-line
comment in front, or highlight ranges of lines using// highlight-start
and// highlight-end
pairs. It looks like the logic is implemented in thisdirectives.js
file.This would be a great addition to the Docusaurus Prism plugin.
In addition, I've seen that many docs websites have code snippets that include a filename in front of the block, such as Gatsby (example) and Ember (example).
Gatsby's Markdown for this looks like:
Have you read the Contributing Guidelines on issues?
Yes
Motivation
Easier line highlights and filenames would be very useful, especially as part of tutorials that are telling users what to edit.
The text was updated successfully, but these errors were encountered: