Re: [code] Re: Improve the strong and emphasis of markdown lexer

From: Mitchell <m.att.foicica.com>
Date: Thu, 9 May 2019 21:49:11 -0400 (EDT)

Hi Alexander,

On Wed, 8 May 2019, Alexander Misel wrote:

> Minor improvement for cases like _aa_bb_cc_:
> local punct_space = lexer.punct + lexer.space
>
> function flanking_between(s, not_inword)
> local fl_char = lexer.any - s - lexer.space
> local left_fl = B(punct_space - s) * s * #fl_char + s * #(fl_char - lexer.punct)
> local right_fl = B(lexer.punct) * s * #(punct_space - s) + B(fl_char) * s
> return left_fl * (lexer.any - (not_inword and (s * #(punct_space + P(-1))) or s))^0 * right_fl
> end
>
> lex:add_rule('strong', token('strong', flanking_between('**') + (B(punct_space) + #lexer.starts_line('_')) *
> flanking_between('__', true) * #(punct_space + P(-1))))
> lex:add_style('strong', 'bold')
>
> lex:add_rule('em', token('em', flanking_between('*') + (B(punct_space) + #lexer.starts_line('_')) *
> flanking_between('_', true) * #(punct_space + P(-1))))
> lex:add_style('em', 'italics')

Thank you, I will take a look when I have some time.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 09 May 2019 - 21:49:11 EDT

This archive was generated by hypermail 2.2.0 : Fri 10 May 2019 - 06:40:10 EDT