-
Notifications
You must be signed in to change notification settings - Fork 14
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
Custom programming language highlighting #344
Comments
This is definitely a good thing to support. There are a few barriers right now. The two major syntax highlighting libraries are PrismJS and HighlightJS. I chose Prism because it's more modular, which is key for being able to ship books with different language support dynamically with Svelte. Unfortunately, making this work requires ESM support, which PrismJS will release with v2, which isn't out yet, and progress seems to have stalled. Switching to HighlightJS isn't really an option either, since it uses a DOM manipulation approach, which breaks with Svelte. No good solutions for this yet that don't involve manually adapting Prism language definitions, hence the limited language support. One workaround for this would be just adding Rust support. It wouldn't increase the size of the book bundles too much to add this, and it's common enough. See ExtendedPrism.js for where the manual language definitions are added. |
Thanks for the rundown. I'm focusing on content before highlighting but if
I ever write my own style files I'll absolutely send them your way
…On Sat, Jun 10, 2023, 11:43 AM Amy J. Ko ***@***.***> wrote:
This is definitely a good thing to support. There are a few barriers right
now. The two major syntax highlighting libraries are PrismJS
<https://prismjs.com/> and HighlightJS <https://highlightjs.org/>. I
chose Prism because it's more modular, which is key for being able to ship
books with different language support dynamically with Svelte.
Unfortunately, making this work requires ESM support, which PrismJS will
release with v2, which isn't out yet, and progress seems to have stalled.
Switching to HighlightJS isn't really an option either, since it uses a DOM
manipulation approach, which breaks with Svelte. No good solutions for this
yet that don't involve manually adapting Prism language definitions, hence
the limited language support.
One workaround for this would be just adding Rust support. It wouldn't
increase the size of the book bundles too much to add this, and it's common
enough. See ExtendedPrism.js
<https://github.com/amyjko/bookish/blob/2c927dc08d5361e6445386f09ac4e27db705e5eb/src/lib/components/chapter/ExtendedPrism.js#L5>
for where the manual language definitions are added.
—
Reply to this email directly, view it on GitHub
<#344 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAO6WYO4VVRXZ2U6CDVXRIDXKSI3ZANCNFSM6AAAAAAY3UVKFU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I'm assuming that the code highlighting feature uses some sort of syntax highlighting library for which you created or found theme files to support the given programming languages, if not, then this request might not apply.
The motivation is that my book is a programming languages textbook, and it includes programming languages where I would not really think it fair to ask you to go out of your way to implement them for me, but I'd like to implement them:
and I'm probably leaving some out.
I would potentially be open to developing styles for these languages which you could make available to everybody, but I'm aware the quality may not be high enough for reuse
The text was updated successfully, but these errors were encountered: