Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown lexer: two blockcode errors #93

Open
Disonantemus opened this issue Apr 17, 2023 · 3 comments
Open

Markdown lexer: two blockcode errors #93

Disonantemus opened this issue Apr 17, 2023 · 3 comments

Comments

@Disonantemus
Copy link

Fenced blockcode with tilde (commonmark spec) it's not supported

Fixed this (I'm not a programmer and i don't know how to PR), adding this line after local code block =

local code_block_tilde = lexer.range(lexer.starts_line('~~~'), '\n~~~' * hspace^0 * ('\n' + P(-1)))

And then changed this line to include tilde block type:

lex:add_rule('block_code', token('code', code_line + code_block + code_block_tilde + code_inline))

Blockcode (line, not fenced) error (edge case with lists inside)

Markdown example (indent using Tabs or 4 spaces to get blockcode line):

	This
	* Whole
	+ Paragraph
	- Should be
	a Blockquote

But I get blockcode only first & last line, I think the other lines are recognized as list.

I've tried 2 fix this, but it's tied with lists and fixing one damage the other.


Tested expected behavior with Github and:

@orbitalquark
Copy link
Owner

Thanks for the report. I'll look into this when I have some time.

@orbitalquark
Copy link
Owner

I've implemented ~~~ code blocks here: fc89283

As for the second issue you pointed out, there are two problems:

  1. The issue you pointed out with only the first and second lines being recognized as code blocks.
  2. If you remove the This line, the last line should be recognized as part of the list on the previous line. Instead it's recognized as a code block.

I spent some time investigating and trying things out, but I cannot figure out how to solve this. Markdown is very weird. It's possible another lexer rewrite will be needed to correct this, but I honestly don't know how I'd approach that. I'm afraid I'll have to leave this unresolved for now :(

A workaround for your case is to wrap it all in a fenced code block (backticks or tildes). I don't have a workaround for the second case I brought up.

@rgieseke
Copy link

rgieseke commented Sep 4, 2023

FWIW, there is Lua Markdown parser implementation from John McFarlane of Pandoc/Commonmark.
Maybe it could be adapted as a Textadept lexer.

https://github.com/jgm/lunamark/blob/master/lunamark/reader/markdown.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants