zsh-users
 help / color / mirror / code / Atom feed
* Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.
@ 2018-07-30  7:09 Sebastian Gniazdowski
  2018-07-31  4:16 ` Sebastian Gniazdowski
  2018-08-01 18:18 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Sebastian Gniazdowski @ 2018-07-30  7:09 UTC (permalink / raw)
  To: Zsh Users

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-02  7:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30  7:09 Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH Sebastian Gniazdowski
2018-07-31  4:16 ` Sebastian Gniazdowski
2018-07-31  5:13   ` Sebastian Gniazdowski
2018-08-01 18:18 ` Bart Schaefer
2018-08-02  7:32   ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).