This problem that seems trivial is beating me real hard.
I'm trying to create a couple of syntax highlighting directives for a custom language that is structured in paragraphs separated by at least one empty line. The language specifies that paragraphs can eiter:
- End with punctuation
- End without punctuation
Each of these cases must have different highlighting properties. On the images below I have one example structure demonstrating what I need to achieve:
Case 1: Paragraphs that ends with some punctuation comprises one highlighting group:
Case 2: Paragraphs that ends without punctuation comprises another highlighting group:
I got no luck with syn region
, since there are no constant start/end characters surrounding the blocks of text, so I'm trying to solve this with syn match
and thus I'm exploring the possibilities with complete regexes.
First I've verified that \n$
correctly maps to the end of every paragraph, and that ^$\n
correctly maps the empty lines, so I composed them as follows:
^$\n\_.\{-}\n$
Which matches all paragraphs except the first one. So I implemented:
\(\%^\|^$\n\)\_.\{-}\n$
Which correctly matches all paragraphs, but when I tried to account for the punctuation:
\(\%^\|^$\n\)\_.\{-}\.\n$
It became clear that the \_.
operator, even with the non-greedy multi \{-}
just ignores the \.
bit on the rule, and will match every paragraph from the start of the file, even the ones that do not end with a .
, up to the last paragraph on the file that ends with a .
. The weird thing to me is that even that it matches every paragraph on the file up to the last one ending with a .
, the match returns a distinct result count (more than one result). In this case I would expect a single match. What is happening here?
So, I've read all the manuals and I'm clueless regarding what strategy to use from here.
Any help will be greatly appreciated. Thank you!