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

ReSpec build script: no automatic syntax highlighting for unspecified or "unknown" languages #4107

Merged
merged 5 commits into from
Sep 26, 2024

Conversation

ralfhandl
Copy link
Contributor

@ralfhandl ralfhandl commented Sep 23, 2024

We intentionally format code blocks with highlight.js if the explicitly specified language of the code block is known to this package.

Formerly we left highlighting of unknown languages or code blocks with unspecified language to ReSpec, which now leads to erratic results, see #4103.

This PR suppresses automatic syntax highlighting by ReSpec for code blocks whose language is not specified or unknown to highlight.js.

It also adds two custom languages uri and uritemplate that are used in

Preview:

image

Jay, I had a test for this 😄
@ralfhandl ralfhandl changed the title ReSpec build script: no automatic syntax highlighting for "unknown" languages ReSpec build script: no automatic syntax highlighting for unspecified or "unknown" languages Sep 23, 2024
@handrews
Copy link
Member

handrews commented Sep 23, 2024

Can we update highlight.js to get more languages? I really wish urlencoded highlighting were supported (I believe it's possible). (I'm not blocking on this, just don't have time to properly review this morning and wanted to ask before I forgot)

@ralfhandl
Copy link
Contributor Author

Can we update highlight.js to get more languages?

We are already using the latest version of highlight.js, and we can either try to find a supported language that looks nice for URL templates and query parts, or register a custom language for it:

image

Both approaches would require to differentiate between uritemplate and urlencoded, otherwise URI templates will look funny:

image

@handrews
Copy link
Member

At least some packages have plugins for urlencoded. Not sure I’ve seen uritemplates but yes def different format!

@ralfhandl
Copy link
Contributor Author

@handrews Copied some snippets I found on StackOverflow and it now looks better than all-black or all-red.

If you have a better copy template, please tell me.

Copy link
Member

@handrews handrews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @ralfhandl this is fantastic! I verified it in a local build.

@handrews handrews merged commit e9b9785 into OAI:main Sep 26, 2024
2 checks passed
@ralfhandl ralfhandl deleted the fix/respec-erratic-syntax-highlighting branch September 26, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants