Apart from the usual bug fixes, the main novelties of this release are:
- Language definition for S-Lang (thanks to John E. Davis)
- Perl and Javascript highlighting was improved
- C-style comments are not defined as nested (I swear I never knew this, though I've been programming in C++ and Java for years... shame on me :-)
- The padding character of line numbers can be specified (it does not have to be 0, e.g., it could be a blank space), thanks to Roger Nilsson.
With dynamic backreferences you can refer to a string matched by the regular expression of the first element of a
delim
specification. This is crucial in cases when the rigth delimiter depends on a subexpression matched by the left delimiter; for instance, Lua comments can be of the shape --[[ comment ]]
or --[=[ comment ]=]
, but not --[=[ comment ]]
neither --[[ comment ]=]
(furthermore, they can be nested). Thus, the regular expression of the right element depends on the one of the left element. A dynamic backreference is similar to a variable, but there's no declaration, and have the shape of
@{number}
where number
is the number of the marked subexpression in the left delimiter (source-highlight will actually check that such a marked subexpression exists in the left delimiter).
For instance, this is the definition of Lua comments (see also lua.lang):
environment comment delim `--\[(=*)\[` "]" + @{1} + "]"
multiline nested begin
include "url.lang"
...
end
Notice how the left delimiter can match an optional =
, as a marked subexpression, and the right delimiter refers to that with @{1}.
Source-highlight will take care of escaping possible special characters during dynamic backreference substitutions. For instance, suppose that you must substitute |
for @{1}, because we matched |
with the subexpression [^[:alnum:]]
in a delim element like the following one:
comment delim `([^[:alnum:]])` @{1}
Since |
is a special character in regular expression syntax source-highlight will actually replace @{1}
with \|
.
http://nilrogsplace.se/webdesign/rapidweaver/plugins/high-light/index_en.html