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

Custom programming language highlighting #344

Open
rbohrer opened this issue Jun 6, 2023 · 2 comments
Open

Custom programming language highlighting #344

rbohrer opened this issue Jun 6, 2023 · 2 comments
Assignees
Labels
feature Something new Bookish could do writing Related to book authoring.

Comments

@rbohrer
Copy link

rbohrer commented Jun 6, 2023

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:

  • Rust (critical to the book)
  • Scala (not critical to the book but I wrote it already)
  • Processing (not critical)
  • the Penrose diagramming language (not critical)
  • Inform 7 (not critical)
    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

@amyjko amyjko self-assigned this Jun 10, 2023
@amyjko amyjko added defect Something isn't working as intended writing Related to book authoring. labels Jun 10, 2023
@amyjko
Copy link
Owner

amyjko commented Jun 10, 2023

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.

@amyjko amyjko changed the title Enhancement Request: Enable uploading custom PL highlighting styles Custom programming language highlighting Jun 10, 2023
@amyjko amyjko added this to the 1.0 milestone Jun 10, 2023
@rbohrer
Copy link
Author

rbohrer commented Jun 12, 2023 via email

@amyjko amyjko added feature Something new Bookish could do and removed defect Something isn't working as intended labels Jun 24, 2023
@amyjko amyjko removed this from the 1.0 milestone Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something new Bookish could do writing Related to book authoring.
Projects
None yet
Development

No branches or pull requests

2 participants