You don't need a `#lang` to use `color:text<%>`: I've used it to do basic syntax highlighting for XML. In fact, you don't even need a GUI for the relevant part of the protocol, which is what `#lang`s implement. The requirements are described in the documentation <https://docs.racket-lang.org/framework/Color.html> for the `get-token` argument to the `start-colorer` method. There are specific requirements on how the function must behave to support efficient interactive re-tokenization: these are overkill for an ahead-of-time syntax highlighter, but if your lexers can meet those requirements, they should be usable for a wide range of tasks.
I have a theory that you could use delimited continuations to help with some of the bookkeeping, with the continuation becoming (part of?) the "mode" value passed between calls to the `get-token` function. -Philip On Thu, Feb 20, 2020 at 12:15 AM Sorawee Porncharoenwase < sorawee.pw...@gmail.com> wrote: > > On Wed, Feb 19, 2020 at 11:55 PM Sage Gerard <s...@sagegerard.com> wrote: > >> I'm very much in favor of interoperability and am happy to work in that >> direction. Does this imply that we need a #lang for each highlighting >> target? > > > With my approach, yes, but note that technically, the #lang doesn't need > to be functional. The whole module could just expand into a raising of a > runtime exception "not implemented". I'm not sure that in practice this is > a good idea though. > > >> What happens if you want to highlight code mixtures? Some snippets of >> interest to me can include Javascript, Markdown, CSS, HTML and Racket all >> within 20 lines. >> > > Then the color lexer would need to be context-sensitive and knows when to > switch its lexing mode. Note that this is not a problem due to this > approach. Any other approaches would have the same problem. > > It would be cool if there's a way to annotate code with `#reader` at the > meta level, which would make this problem much easier... > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CADcuegs-76-meLv7Lmr7enGy47fUqGeJChwq%2B%2B9Xbk7b%2Bz6GgQ%40mail.gmail.com > <https://groups.google.com/d/msgid/racket-users/CADcuegs-76-meLv7Lmr7enGy47fUqGeJChwq%2B%2B9Xbk7b%2Bz6GgQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAH3z3gby180aDNWhO8fpy7fXZ-j7W9D8_EAGi30%2BPan3LT%2BzFw%40mail.gmail.com.