Hi Victor,
A clever script indeed. However I'm afraid I don't understand the meaning of the superscript numbers `1, 2, 3, 4` surrounding regexes (e.g. `'¹([^¹]*)¹'`) and replacement groups. Kind of backreferences?
I need to understand this because I'd like to use your **syntax.js** in my static site and write the necessary regexes for CSS and Nunjucks.
Hi, glad you liked it. I break down the conversion in two steps: first I mark the text with the ¹²³.. to delimiter what is a reserved word, what is a method and what is a variable or comment. after that I assign spam elements to each one of the cases. that makes it easy to implement new rules and also one regex don't interfere with the other. think if I turn something into a spam element and the I look for a variable: I would find the <spam class="reserved">reserved_word</spam> and think "reserved" is a string variable, which is not the case.
Let me know if I helped. Bye
Perfectly understood. Thanks a lot.
I'll use it with **Eleventy** SSG and generate code at build.
I'll try to write **HTML**, **CSS** and **Nunjucks** regexes.
One or two things I'll change:
+ change the `<spam>` tag for a `<b>` or `<i>` tag to reduce file size (every byte matters).
+ classify keywords in differentiated categories to highlight them accordingly.
I'll let you know when I'm ready. Bye.