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

[Feature Request] add highlight.js to auto detect code language #236

Open
badrelmers opened this issue May 1, 2024 · 2 comments
Open

[Feature Request] add highlight.js to auto detect code language #236

badrelmers opened this issue May 1, 2024 · 2 comments
Labels

Comments

@badrelmers
Copy link

badrelmers commented May 1, 2024

Hi,
PrismJS does not autodetect code language PrismJS/prism#1313
can you add an option to select between PrismJS and https://highlightjs.org/ because highlightjs can auto detect the language. if you do not like this idea can you please at least add the trick described here to add autodetect to PrismJS? it is only 3 lines of code:

<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
<script>
	document.addEventListener("DOMContentLoaded", function () {
		hljs.highlightAll();
	})
</script>

i open a lot of markdown files with code snippets without a defined language so autodetection will help a lot with that.

@simov simov added the content label May 1, 2024
@simov
Copy link
Owner

simov commented May 1, 2024

Thanks for the feedback. I did not think about that use case. I thought that using fenced code blocks with language labels was something that most people do.

@badrelmers
Copy link
Author

Thank you for looking into this.

I thought that using fenced code blocks with language labels was something that most people do.

Yes this is true when i create the markdown my self, but in general and most cases i just copy already made snippets found in internet which in a lot of cases does not include the language tag, see this example:
say for example i found an interesting code in some site that i want to save as markdown, so i use Copy as Markdown , it is able to add the language if the site use language-* class, but a lot of sites does not add it or use a different class , see for example this mozilla snippet they use brush: js , so Copy as Markdown will create a fenced code without the language. this happens in a lot of sites so you end up with a lot of code snippets without language tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants