Open ygra opened 8 years ago
This is unfortunately one of the limitations of the language grammar in Atom. Here's the related issue in the module that provides grammar support: https://github.com/atom/first-mate/issues/57
The Markdown grammar solves this problem by using begin and end instead of match. We could do that, but we'd have to limit the scope of what is matched in between (the nested scope). Currently, the Markdown grammar permits blank lines, which isn't a valid range. We'd need to be more specific.
I thought this was just my setup. In that case we'd have to rewrite the multi-line parsers to begin and end statements. Too bad :cry: Makes sense performance-wise, but more complicated to write, and deviates further from the upstream asciidoctor.rb regex's.
I agree, it will be a bit tougher and slower. It would be nice if match supported contiguous lines.
Having said that, the nested pattern should just be (.+?)
followed by the end match inside of a (?=)
clause.
For the unconstrained, it's something like (without the attribute list):
{
'begin': '\*\*(?=.)
'end': '(?<=.)\*\*'
'name': 'markup.bold.asciidoc'
'patterns': [
'match': '.+?(?=\*\*)'
]
}
The constrained is a bit more tricky, but still doable I think.
Once we figure it out for one formatting type, it should be easy to port to the other types.
This shouldn't be too difficult, taking the bold highlight as an example.
Multi-lines support cause many regressions, Atom have a very very bad parser...
I think we must target a good inline support before try do "exotic" multi-lines support.
I agree. We seem to have discovered a serious weak spot in the extent of what a grammar can cover. One of the most important steps we can take is to start working upstream to ensure that authors are aware that we absolutely need a way to constrain what is matched between the begin/end boundaries. Perhaps talking to them we will learn something.
In the meantime, we should switch back to matching only single lines for inline formatting until we can do multi-line support safely.
E.g.
Apparently the grammar only checks for those in a single line, although Asciidoctor doesn't care how many lines a paragraph spans.