Skip to content
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

Highlight tokens in syntax highlighted code #142

Open
dtuite opened this issue Mar 17, 2021 · 2 comments
Open

Highlight tokens in syntax highlighted code #142

dtuite opened this issue Mar 17, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@dtuite
Copy link
Member

dtuite commented Mar 17, 2021

In documentation, we often want to display a code snippet for the user to copy paste but we need them to replace certain tokens in the snippet with their own information in order for it to work correctly. An example might be their GitHub Org name, their email address or their Roadie subdomain.

It would be nice if we could highlight these tokens so they stand out when the code is syntax highlighted.

For an example of us struggling with this problem, see this comment: #137 (comment)

This functionality may give us what we need: https://prismjs.com/plugins/highlight-keywords/

@dtuite dtuite added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 17, 2021
@dtuite
Copy link
Member Author

dtuite commented Apr 1, 2021

I tried the method suggested in https://prismjs.com/plugins/highlight-keywords/

Gatsby's prism plugin doesn't support this (there are a lot of plugins which are not supported because Gatsby is build time and Prism is designed to be client side) and the words we want to highlight are not necessarily "keywords" anyway. They are not easy to target with JS or CSS for unique styling.

This looks to be quite tricky to achieve.

@martina-if
Copy link
Contributor

should we instead aim to do better syntax highlighting in the <pre> tags? or always use the ``` and close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants