Skip to content

Improve lexer embedding (markdown -> html) #190

Description

@fischerling

Hey @orbitalquark, thanks for your work on scintillua.

Unfortunatly, I am really bad with LPEG and therefore reaching out for help.

I would like to have better end rules for embedded lexers, especially latex.

For example the markdown lexer uses a blank line as termination for its embedded html lexer.

-- Embedded HTML.
local html = lexer.load('html')
local start_rule = lexer.starts_line(P(' ')^-3) * #P('<') * html:get_rule('tag') -- P(' ')^4 starts code_line
local end_rule = #blank_line * ws
lex:embed(html, start_rule, end_rule)

It would be really nice if we had a proper way to detect the end of the environment using the embeded lexer (for example the closing html tag or similar the end of a latex environment).

I think the html embedding in markdown can be improved by using html.embed_end_tag.

-- Embedded HTML.
local html = lexer.load('html')
local start_rule = lexer.starts_line(P(' ')^-3) * #P('<') * html:get_rule('tag') -- P(' ')^4 starts code_line
local end_rule = html.embed_end_tag
lex:embed(html, start_rule, end_rule)

I think is is correct but I am not really sure.

Is there any good way to detect the end of an latex environment (\end{...})?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions