ui: fall back to xterm-256color if term initialization fails
[vis.git] / lexers / man.lua
bloba2d6175f580427c5ca4ecc3aff28f054213b6309
1 -- man/roff LPeg lexer.
3 local l = require('lexer')
4 local token, word_match = l.token, l.word_match
5 local P, R, S = lpeg.P, lpeg.R, lpeg.S
7 local M = {_NAME = 'man'}
9 -- Whitespace.
10 local ws = token(l.WHITESPACE, l.space^1)
12 -- Markup.
13 local rule1 = token(l.STRING,
14 P('.') * (P('B') * P('R')^-1 + P('I') * P('PR')^-1) * l.nonnewline^0)
15 local rule2 = token(l.NUMBER, P('.') * S('ST') * P('H') * l.nonnewline^0)
16 local rule3 = token(l.KEYWORD,
17 P('.br') + P('.DS') + P('.RS') + P('.RE') + P('.PD'))
18 local rule4 = token(l.LABEL, P('.') * (S('ST') * P('H') + P('.TP')))
19 local rule5 = token(l.VARIABLE,
20 P('.B') * P('R')^-1 + P('.I') * S('PR')^-1 + P('.PP'))
21 local rule6 = token(l.TYPE, P('\\f') * S('BIPR'))
22 local rule7 = token(l.PREPROCESSOR, l.starts_line('.') * l.alpha^1)
24 M._rules = {
25 {'whitespace', ws},
26 {'rule1', rule1},
27 {'rule2', rule2},
28 {'rule3', rule3},
29 {'rule4', rule4},
30 {'rule5', rule5},
31 {'rule6', rule6},
32 {'rule7', rule7},
35 return M