Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Formatting spanning multiple lines isn't highlighted correctly #64

Open
ygra opened this issue Apr 26, 2016 · 7 comments
Open

Formatting spanning multiple lines isn't highlighted correctly #64

ygra opened this issue Apr 26, 2016 · 7 comments

Comments

@ygra
Copy link

ygra commented Apr 26, 2016

E.g.

This is _some
italic_ text.

Apparently the grammar only checks for those in a single line, although Asciidoctor doesn't care how many lines a paragraph spans.

@mojavelinux
Copy link
Member

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: atom/first-mate#57

@mojavelinux
Copy link
Member

mojavelinux commented Apr 26, 2016

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.

@nicorikken
Copy link
Contributor

nicorikken commented Apr 26, 2016

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 😢 Makes sense performance-wise, but more complicated to write, and deviates further from the upstream asciidoctor.rb regex's.

@mojavelinux
Copy link
Member

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.

@nicorikken
Copy link
Contributor

This shouldn't be too difficult, taking the bold highlight as an example.

@ldez
Copy link
Member

ldez commented Apr 30, 2016

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.

@mojavelinux
Copy link
Member

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.

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

No branches or pull requests

4 participants