asciidoctor / asciidoctor-browser-extension

:white_circle: An extension for web browsers that converts AsciiDoc files to HTML using Asciidoctor.js.
https://chrome.google.com/webstore/detail/asciidoctorjs-live-previe/iaalpfgpbocpdfblpnhhgllgbdbchmia
MIT License
220 stars 50 forks source link

Support the `highlightjs-theme` attribute to use a specific Highlight.js theme #570

Closed Zeneex closed 3 years ago

Zeneex commented 3 years ago

Do the highlightjs-theme option value of github is ACTUALLY hardcoded (can not be changed)? :

return "" + "<link rel=\"stylesheet\" href=\"" + (base_url) + "/styles/" + (doc.$attr("highlightjs-theme", "github")) + ".min.css\"" + (opts['$[]']("self_closing_tag_slash")) + ">"

I just found the abovementioned code in asciidoctor.js in the browser extension folder on my system. I've tried and tried and tried to somehow modify the style/theme the highlighter use for some code snippet of mine... I've read on Internet, used :highlightjs-theme: arta in the asciidoc document head - does nothing. Used the option in the extension settings' options dialog as highlightjs-theme=arta - does nothing. Tried highlightjs-theme=Arta; tried :highlightjs-theme: Arta in head; tried :highlightjs-theme: style/arta in head; tried :highlightjs-theme: styles/arta.css in head; download all the styles locally from the GitHub repo, put them in styles folder of the extension - css/highlight/..., where github.css file resides; tried whatever combination of paths/names/extensions you can think of - does nothing.

Highlighter works, but it always applies the "default" style github.

Is it what I think it is or am I doing something wrong?

ggrossetie commented 3 years ago

The browser extension only include a single theme for Highlight.js, see: https://github.com/asciidoctor/asciidoctor-browser-extension/tree/main/app/css/highlight

And the relevant code that adds the Higlight.js theme:

https://github.com/asciidoctor/asciidoctor-browser-extension/blob/44f78ce9a997cddd4d9ef3408473d5eabba37c16/app/js/renderer.js#L104-L108

In the future, please use the issue title to state the behavior you want rather than commentary about how you feel about the current behavior. That makes the issue actionable.

ggrossetie commented 3 years ago

This issue is actually a duplicate https://github.com/asciidoctor/asciidoctor-browser-extension/issues/63

Zeneex commented 3 years ago

Thanks, Guillaume. I don't use git usually so I'm not familiar at all with titling and everything... Thank you for retitling the issue and everything... So does this mean we can expect :highlightjs-theme: attribute support user-defined theme in the near future or is this functionality in question? (I've read all the #63 issue but I'm still unsure)

Or can I add some (dirty) js code to my distro of the extension to make it work (at least for now) on my machine only? I'm not a developer or coder or anything... just a simple user - anything more than a .js file seems alot of code to me and the extension has more than 1 file :), so any help in that direction would be appreciated.