ChrisPenner / rasa

Extremely modular text editor built in Haskell
GNU General Public License v3.0
614 stars 42 forks source link

Demo syntax and syntax-markdown extensions #65 #66

Open jmatsushita opened 5 years ago

jmatsushita commented 5 years ago

And building on #65 here's a demo of the syntax modules (for now pinned to github commits). It would be great if you could take a look at

before I make the jump to submit my first packages on hackage?

The idea is that a syntax extension implements

type Lexer a = Y.YiString -> Tokens a
type Styler a = TokenRange a -> BufAction (Span CrdRange Style)
type Mapper = [Extension]
data Syntax a = Syntax String Mapper (Lexer a) (Styler a)

for instance:

markdown :: Mapper -> Syntax MarkdownToken
markdown mapper = Syntax "Markdown" mapper lexer styler

Which then allows to add extensions like so:

main :: IO ()
main = rasa $ do
  ...
  syntax [markdown [Extension ".md"]]
ChrisPenner commented 5 years ago

I just changed the base branch to be your other feature to clean up the diff while we review it; we'll switch it back to master when we merge 👍