On Sunday, September 19, 2021 at 11:44:13 AM UTC+2 TiddlyTweeter wrote:

*You forgot to mention your own Custom Markup* that can do highlights easy 
> already and more :-)


... Hmmm, It's built for a different usecase. It can do highlights for the 
rendered output. ... The OP is for editor highlighting. 
 

> There is no serious brain science involved in editor markup. 
> It just needs a clever person like you to provide the way to engage a 
> parser to apply the HTML/CSS as needed in render.
>

As so often, the "devil is in the detail". It's relatively easy to 
performantly highlight 100 lines of code, but it's really hard to be fast, 
if you highlight 100.000 lines of code. .. Rightclick tiddlywiki.com and 
choose "Show Code" .. It's about 40.000 lines .. 

It's easy to highlight a full code structure. Eg 

If (a == b) {
  do this
else {
  do that
}

But what if the else { element is 300 lines away out of the screen and 
isn't even rendered or in memory, since we can't see it anyway. The 
highlighter still needs to show something that is valid. ... Because the 
source text can be long we only can render what fits on the screen, +- 100 
lines to satisfy page-up and page-down 

There is a reason why the codemirror base-plugin is 166kByte as a minified 
file. 

You are right, there is a lot of editor-overhead in the code, but that's 
mainly because of browser quirks, at the times where the library was 
created. 

I think we making a mountain out of a molehill. 
> *Your Custom Markup *is really good in solving this kind of issue easily.
>

Not as a syntax highlighter in edit mode.
 

> A think its *Generic Solutions*  much better long term already. It it 
> much better to have one logic than several.
>

That's right. But they have to be built for exactly that purpose. Sadly, 
for syntax highlighting there is no "1 size fits all" [1] approach. 

There is codemirror-6 <https://codemirror.net/6/> which created it's own Lezer 
Parser <https://lezer.codemirror.net/> system as a generic solution, that 
creates language specific highlighter modules, based on a language  
specific grammars. .... There _is_ a lot of science involved, if you want 
to create generic tools for syntax highlighting. 

have fun!
mario
PS [1] I did write this sentence and then looked up the Lezer Parser 
documentation  page :)

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/49c43f68-f338-4a0c-8972-250266db74a6n%40googlegroups.com.

Reply via email to