This is a demo of an interactive syntax highlighting editing window for the Haskell language, writtein in Elm, mainly for the purposes of learning Elm but also so that the foundations of this demo can be turned into a syntax highlighting framework.
The Haskell syntax parser currently is unable to parse anything context
sensitive, as it is a line by line parser as it is currently designed. This is
to get line numbering to work as expected without having to make exceptions for
what to do with multiline facilities. Adding in context can also let us parse
the identifier differently in a type signature as well as only highlight things
that are getting a definition (e.g.
main = print 0 would highlight
The main ideas towards getting this to work as expected are as follows:
textareahas transparent foreground color and transparent background, but is placed on top of the backdrop.
- The backdrop contains an idendical but marked up copy of the
textareaand the transparency allows the text to be shown and it creates the illusion that the
- Scrolling is applied to the backdrop from values from the
textareato sync the two together. This is done via
The actual code to mark up a
Source is not very complicated. Once a
representation is obtained it has a mostly 1-1 correspondence with the
that appear in the DOM. The language parser is also probably not idiomatic Elm
but coming from a Haskell background, it's what makes the most sense for me to
write at this current point in time.