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

Create an "opaque" comment macro to hide part of the code to the syntax checker. (low priority!) #2171

Closed
Rmano opened this issue Sep 15, 2021 · 6 comments

Comments

@Rmano
Copy link

Rmano commented Sep 15, 2021

There are, in the wild, "funny" templates that do very strange things; sometimes it would be useful to mark part of your text/code as invisible for the syntax highlighter parser. I will male just an example here...

For example, the MDPI journal templates issues a \begin{paracol}{2} which is hidden into the \begin{document} command. At a later stage in the document, you are required to issue a \end{paracol} (just before wide figures, for example, and before bibliography); see https://tex.stackexchange.com/questions/606008/wide-table-using-mdpi-template/606032#606032. I am unable to produce a small example, but this thing for example disrupts the backward search from PDF in my vimtex.

But in general, my point is that this is often a smash-a-mole thing, similar things can appear everywhere and it is impossible to take into account all the times some package makes an utterly ugly thing like that.

Overleaf has a nice mechanism for this: everything between the two magic comments

%%begin novalidate
...
%%end novalidate

is completely ignored by code check, syntax highlight, etc.

Wouldn't that be a nice "last-resort" thing to have?

@lervag
Copy link
Owner

lervag commented Sep 15, 2021

VimTeX has a similar feature for syntax highlighting, see :help vimtex-syntax:

There will probably always be situations where the parser will fail, and in
some cases it may be hard to "recover". It is therefore possible to manually
activate a severely reduced syntax zone to handle such situations. The zone is
activated with the directive `% VimTeX: SynIgnore on` and disabled with the
similar directive `% VimTeX: SynIgnore off`, e.g.: >

  % VimTeX: SynIgnore on
  \catcode`\$=11
  $
  \catcode`\$=3
  % VimTeX: SynIgnore off

The above LaTeX code will look plain, but OK with VimTeX. Note: The directive
is matched case insensitive, and the synonyms `enable` and `disable` may be
used instead of `on` and `off`.

It could be relevant to also support the same magic comment as Overleaf uses. Do you thank that is necessary?

Also: do you find a need for something in addition to this from VimTeX side?

@Rmano
Copy link
Author

Rmano commented Sep 15, 2021

Ah, I did not know of that feature! Sorry for the noise.

@Rmano Rmano closed this as completed Sep 15, 2021
@lervag
Copy link
Owner

lervag commented Sep 15, 2021

No problem! The overleaf mechanism still looks nice to support from VimTeX as well? Afterall, it is quite easy to work locally towards Overleaf through the git integration...

@Rmano
Copy link
Author

Rmano commented Sep 15, 2021

Yes --- that could be nice!

I work a lot locally with the overleaf-github link (so I can edit with vimtex locally, and still have online collaboration with my co-authors). Now I have the comments duplicated, but it would be nice if the overleaf comment would be understood by vimtex, too.

@lervag
Copy link
Owner

lervag commented Sep 15, 2021

Done!

@Rmano
Copy link
Author

Rmano commented Sep 15, 2021

Thanks!

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

No branches or pull requests

2 participants