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

Incorrect highlighting of lines following embedded directive #53

Open
smackesey opened this issue Apr 7, 2020 · 2 comments
Open

Incorrect highlighting of lines following embedded directive #53

smackesey opened this issue Apr 7, 2020 · 2 comments

Comments

@smackesey
Copy link

The lines following a directive embedded in a definition list definition are not correctly highlighted. See screenshot:

highlight

The "yada yada yada" should not be highlighted as if it were part of the directive, as it is not at the indentation level to include it in the directive.

@marshallward
Copy link
Owner

Thanks for reporting this, I can reproduce it.

This has been a longstanding problem (see #3, probably others), but fortunately we have found a way to fix it in literal blocks (see this example file).

The method has not yet been extended to code blocks and other but it should be use the same technique to fix this.

@marshallward
Copy link
Owner

These are mostly notes to myself, but might be helpful to anyone interested.

Directives are going through the "old" methods, which rely on the rstExplicitMarkup = ^\s*\.\.\_s match to begin any directive. The disadvantage is that we then discard this leading whitespace in subsequent matches and are unable to align.

Some steps were taken to address this in .. code:: directives (rstCodeBlock), but were always somewhat incomplete and were never extended to more general directives (rstExDirective).

This was revised in the rstLiteralBlock region by tracking this whitespace (in a \z group, followed by a \@<= to do a back-match) and using it in the end match. One of the reasons we could tackle this separately is because it never relied on rstExplicitMarkup.

The technique ought to work in other groups, but would need to be applied in some way which either modifies, replaces, or abandons the rstExplicitMarkup match.

Some decisions need to be made here, but it should be possible to resolve all of these cases in the same way.

(Also worth noting that use of \@<= is generally discouraged because of bad performance, so something to watch out for if this is ever addressed.)

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

2 participants