-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Added syntax highlighting to code-blocks (and it works!) #2198
Conversation
# Conflicts: # package-lock.json # src/public/app/services/note_content_renderer.js # src/public/stylesheets/style.css # src/routes/api/files.js # src/routes/routes.js
# Conflicts: # package-lock.json
# Conflicts: # package-lock.json # package.json # src/public/app/entities/note_short.js # src/public/app/services/protected_session.js # src/routes/api/login.js
Hi, interesting work, but as you mention it's rather a POC and this is not going to get merged. The next step would be to get required changes in the fork of |
I would like to see this feature implemented.
Is this likely to happen? |
Not from my side. Just a hint for somebody who would like to give it a shot. |
Hey I've been busy lately and probably won't have the time in the near future to refine the POC and submit a PR to ckeditor. Feel free to play around with it though, there are instructions provided in the repo on how to replicate the whole process. |
Check #2822 for a simpler solution |
@TuxTheXplorer , are you still interested in contributing to Trilium? If so, I think your knowledge with working on the CKEditor might come in useful for TriliumNext/Notes#20 where we'd like to add this feature as a first-class citizen. |
Hi,
This PR showcases the possibility of adding syntax highlighting to code-blocks (finally!) within normal text notes.
It is achieved by combining the CKEditor5-CodeBlock-With-Syntax-Highlight plugin with the trilium-ckeditor5 repo, then swapping the newly built ckeditor into trilium. After this is done, it is necessary to make small edits to the source files of trilium by changing the mime types from
text/x-language
to simply theirlanguage
part (or their highlight.js supported equivalent).In my repo I've included a
build.sh
file, which does all of the below automatically and creates a fresh build with 4 example languages ready to be used within code blocks (plaintext, c, php, python).I've created this as a proof of concept to show that it is possible to add syntax highlighting to trilium, albeit by jumping through a couple hoops. I don't expect this PR to be accepted, I only intended it to be used as a heads-up about the possibilty of implementing syntax-highlighting. I hope this could help development and that we see syntax highlighting implemented sometimes in the future.
Some quirks about the current state of the demo:
Overall description of how this thing works
The overall process of adding syntax highlighting to trilium is as follows:
text/x-language
with the correct alias of the language from the highlight.js supported languages list