Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.
- X-seq: zsh-users 23546
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.
- Date: Mon, 30 Jul 2018 09:09:02 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=miosoEk0XzMl/5UsjHtozEzEagyiIG+pOqLpXBE4e1o=; b=vEb7F4CHRcmsQlS0Eu1jH2YDXdlxSbEX+Gf8BnUaP1Xf/wCQhF+qq36D2L7rDQC2rj eyC5x8A1sqKFg1V7rxBBjY9IPQsuYEkrzFf/1G9OApwYBhCqnOzlN4Qf0O/JhvYIZNvs wqjm6drXVMaRC7QUBCjkv2u/F45YkxkeA8lCfcLVx755JfWIdyHv9e3divLNXHnYuIFV vdEpHZ2F6qMk3/irm7hLpicc4mK2C8fiKyRMpwojEtppFttQ7rKc39pnahyY6aXaLxG6 XMCW3rL4lKeaoa/GQerImgj7Mmc2Qqt5FLb95Q3wSnXuhc7DljKg6qBTUUAzYm7kq0gQ Cq6w==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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