marshallward / vim-restructuredtext

Syntax file for reStructuredText on Vim.
26 stars 12 forks source link

substitution references may contain spaces #9

Closed anntzer closed 7 years ago

anntzer commented 8 years ago

The following example is from http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-definitions:

|The Transparent Society| offers a fascinating alternate view
on privacy issues.

.. |The Transparent Society| book:: isbn=0738201448

rst.vim currently does not highlight .. |The Transparent Society| as a reference due to the presence of spaces.

marshallward commented 8 years ago

Yeah, confirmed. Looks like rstSubstitutionDefinition is borrowing the rules for single-word references. Thanks for finding it.

marshallward commented 8 years ago

This should be fixed now. I've introduced a PhraseReference definition alongside the single-word ReferencePhrase. Can you try it out?

anntzer commented 8 years ago

Works for me, thanks!

anntzer commented 7 years ago

Actually, substitution references may simply contain any character (vertical bars must be escaped of course) (http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup). Thus, while I didn't find this explicitly in the text, it is reasonable to believe that their definitions may also contain arbitrary text.

See https://raw.githubusercontent.com/anntzer/mplcursors/master/README.rst /https://github.com/anntzer/mplcursors/blob/master/README.rst (the gitter link) for a real-life example, which indicates that this is indeed docutils' behavior.

Accordingly, can you reopen the issue? Thanks in advance.

I guess it may be possible to hack Define{,One}InlineMarkup to make the make the defined group optionally contained, but I haven't been successful trying that.

marshallward commented 7 years ago

Maybe just wildcard the whole thing then? (Maybe also redefine as a region with a skip for escaped | ?)

Something like this:

execute 'syn match rstSubstitutionDefinition contained' .
  \ ' /|.*|\_s\+/ nextgroup=@rstDirectives' 
anntzer commented 7 years ago

No strong opinion as to the best way to implement this.

marshallward commented 7 years ago

I'll do the wildcard for now, and wait for the inevitable problems to emerge :)

marshallward commented 7 years ago

Changed in 6da8601 will close if it all looks good.

anntzer commented 7 years ago

Well, looks good enough for until next time I find something :-)