Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.



Hello,
not only (z) can handle quoting, turns out regular pattern with while
loop can do it too:

    while [[ $_mybuf = (#b)[^"{}()[]\\\"'"]#((["({[]})\"'"])|[\\](*))(*) ]]; do
        [[ -n "${match[3]}" ]] && {
            __idx+=${mbegin[1]}+1
            _mybuf="${match[3]:1}" # also skip 1 quoted char
        } || {

the main point is [\\](*). Parentheses are placed in ${match[3]} and
allow to restart processing skipping e.g. a quoted backslash.

The rest is matching braces – it's an example from
Fast-Syntax-Highlighting, it now has ideal brackets highlighting – AND
ALSO ", '. Simple handling of those two quotings allows to switch mode
"in quoting" "outside quoting". That's all. The effect:

https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/brackets.gif

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin



Messages sorted by: Reverse Date, Date, Thread, Author