rubychan / coderay

Fast and easy syntax highlighting for selected languages, written in Ruby.
http://coderay.rubychan.de/
Other
846 stars 115 forks source link

How should scanners be created where there exist multiple dialects of the same language? #180

Closed vermiculus closed 9 years ago

vermiculus commented 9 years ago

Since I use Jekyll for my blog and would like to use CodeRay for syntax highlighting, I'm planning on submitting a PR for TeX, LaTeX, and expl3 scanners and encoders.

My query is on how to organize / relate these three closely related languages. TeX is very simple – containing only a few special constructs (\def\foo#1{(#1)}), LaTeX has a couple of other ideas added onto it, and expl3 is a full-blown programming language with decently intricate syntax. How should I relate them, if at all?

korny commented 9 years ago

Scanners shouldn't have required options, so something like a TeX scanner that needs a dialect parameter would be inconvenient. If you can write a Scanner that handles all dialects, or easily find out (looking at the content) which dialect it is, you should implement this in one Scanner. Otherwise, each dialect should have its own Scanner. You're free to use inheritance; for example, the Groovy scanner inherits from Java.