blob: e6a33051cf568ab1af748c2b4b0b3ad162cc1bfb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
-- Copyright 2006-2025 Robert Gieseke. See LICENSE.
-- Literate CoffeeScript LPeg lexer.
-- http://coffeescript.org/#literate
local lexer = lexer
local P, S = lpeg.P, lpeg.S
local lex = lexer.new(..., {inherit = lexer.load('markdown')})
-- Distinguish between horizontal and vertical space so coffee_start_rule has a chance to match.
lex:modify_rule('whitespace', lex:tag(lexer.WHITESPACE, S(' \t')^1 + S('\r\n')^1))
-- Embedded CoffeeScript.
local coffeescript = lexer.load('coffeescript')
local coffee_start_rule = #(P(' ')^4 + P('\t')) * lex:get_rule('whitespace')
local coffee_end_rule = #lexer.newline * lex:get_rule('whitespace')
lex:embed(coffeescript, coffee_start_rule, coffee_end_rule)
return lex
|