dhowe / rita

Website, documentation and examples for RiTa
https://rednoise.org/rita
71 stars 9 forks source link

Syntax highlighting mode for RiScript in highlight.js #68

Open dhowe opened 3 years ago

dhowe commented 3 years ago

@Real-John-Cheung can you look into creating a simple syntax highlighting mode for riscript in highlight.js -- the guide is here: https://highlightjs.readthedocs.io/en/latest/language-guide.html

Don't start working on it yet, but just a quick review and an estimate of how many hours are likely required to do the kind of basic highlighting that is in the editor

Real-John-Cheung commented 3 years ago

@dhowe I think it works similarly to CodeMirror, maybe needs 2-3hours

dhowe commented 3 years ago

great, lets make that next priority

dhowe commented 3 years ago

lets also try to use it in the editor, so that we only have to update one place

Real-John-Cheung commented 3 years ago

lets also try to use it in the editor, so that we only have to update one place

I am afraid that it might not be possible since how highlight.js works is that it generally finds content inside \<pre>\<code> and do the highlighting, and CodeMirror rap the content in the editor in just \<pre>... but I will look into it

---------------update--------------------- found a way to fix the above problem, but registering the mode doesn't going so well.... unlike CodeMirror, the distributed highlight.js library has a packing process during build, so the custom mode might also need such a process, we can either do like this or make a 3rd party pack like this?

dhowe commented 3 years ago

yes the 2nd is what I was planning -- so that we can use it on observable:

We're happy to host 3rd party module repos inside the highlightjs organization on GitHub. Just file an issue and request a repository.

Publish it to NPM also if you'd like. This will make it much easier for anyone using Node to use it.

When your language module is ready create a PR that adds it to the README.md file in the list of languages.

See this ticket: https://github.com/highlightjs/highlight.js/issues/2971 for an example

Real-John-Cheung commented 3 years ago

status: now we have a repo for riscript mode here that works, but the auto detection is not ready yet. it is also in the supported languages list of highlightjs now

dhowe commented 3 years ago

@Real-John-Cheung what do we have to do to get this working in observable ? see this ticket: https://observablehq.com/@bryangingechen/highlightjs-for-lean