jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
194 stars 62 forks source link

Is there a function to which a string containing an XML definition may be passed directly #65

Closed anchpop closed 5 years ago

anchpop commented 5 years ago

In my project, the definitions are embedded in the actual executable and are not present as external files. The only function I can find for creating a Syntax is parseSyntaxDefinition, which takes a filename and, from what I can tell, reads the file at that location and parses it. Is there a function which can parse a String directly?

jgm commented 5 years ago

anchpop notifications@github.com writes:

Is there a function which can parse a String directly?

No, but there should be. This wouldn't be too hard to add. If you look at HXT, there's readFromString (or something) in addition to readDocument, so a few changes in Commonmark.Parser could do the trick.

jgm commented 5 years ago

I've added parseSyntaxDefinitionFromString in master. Try it out.

anchpop commented 5 years ago

Thanks! Works perfectly. This made my day 😊