- nv-macro-quote
- cli tool, unquote mixed-quoted string
- npm install nv-macro-quote -g
Usage: nv_quote [options]
Options:
-i, --input input string ,default stdin
-o, --output output string,default stdout
-n, --naked_str output in naked-str, default true
-s, --str_with_quote output in str-with-quoteformat, default false
-a, --ary output in array-format, default false
-t, --tok output in tok-format, default false
-q, --qpairs SELF DEINED QUOTE-PAIRS,default using -D
-e, --esc ESCAPE-CHAR,default is "\"
-h, --help usage
nv-macro-quote# nv_quote -Q
[ "'", "'" ]
[ "'''", "'''" ]
[ '"', '"' ]
[ '"""', '"""' ]
[ '`', '`' ]
[ '%%', '%%' ]
[ '###', '###' ]
[ '//', '\n' ]
[ '//', '�' ] // ['//',String.fromCodePoint(8232)],
[ '//', '�' ] // ['//',String.fromCodePoint(8233)],
[ '/*', '*/' ]
[ '<', '>' ]
[ '<!--', '-->' ]
[ '{-', '-}' ]
[ '(*', '*)' ]
[ '<%--', '--%>' ]
[ '%(', '%)' ]
[ '#|', '|#' ]
[ '#=', '=#' ]
[ '#if', '#endif' ]
[ '--[[', '--]]' ]
// below are special for chinese-text handle
[ '“', '”' ] // '"'
[ '‘', '’' ] // "'"
[ '·', '·' ] // '`'
nv-macro-quote#
//string-for-test:
`
a"bcd" %%ef%% """gh"""i
/*
jk
lm
*/ #if nopq #endif <!--rrrsssttt-->
##
`
nv-macro-quote# nv_quote -n
a"bcd" %%ef%% """gh"""i
/*
jk
lm
*/ #if nopq #endif <!--rrrsssttt-->
##
////===================>press ctrl+D
{
"toks": [
"a",
"bcd",
" ",
"ef",
" ",
"gh",
"i",
"\n",
"\njk\nlm\n",
" ",
" nopq ",
" ",
"rrrsssttt",
"\n"
],
"lefted": [
[],
"##"
]
}
nv-macro-quote# node cli.js -s
a"bcd" %%ef%% """gh"""i
/*
jk
lm
*/ #if nopq #endif <!--rrrsssttt-->
##
////===================>press ctrl+D
{
"toks": [
"a",
"\"bcd\"",
" ",
"%%ef%%",
" ",
"\"\"\"gh\"\"\"",
"i",
"\n",
"/*\njk\nlm\n*/",
" ",
"#if nopq #endif",
" ",
"<!--rrrsssttt-->",
"\n"
],
"lefted": [
[],
"##"
]
}
nv-macro-quote#
-
if array.length === 3 , its a quoted string [left-q,str,right-q]
-
if array.length === 1 , it a raw string [str]
nv-macro-quote# nv_quote -a a"bcd" %%ef%% """gh"""i /* jk lm */ #if nopq #endif <!--rrrsssttt--> ## ////===================>press ctrl+D { "toks": [ [ "a" ], [ "\"", "bcd", "\"" ], [ " " ], [ "%%", "ef", "%%" ], [ " " ], [ "\"\"\"", "gh", "\"\"\"" ], [ "i" ], [ "\n" ], [ "/*", "\njk\nlm\n", "*/" ], [ " " ], [ "#if", " nopq ", "#endif" ], [ " " ], [ "<!--", "rrrsssttt", "-->" ], [ "\n" ] ], "lefted": [ [], "##" ] }
-
if type === 10, it's a raw-string-tok
-
if type === 12, it's a quote-but-treated-as raw-string-tok here ,(compare .q AND .lq/.rq)
-
if type === 100, it's a quoted-string-tok (.lq,.rq,.q, .str; compare .q AND .lq/.rq will know if it's open OR close)
nv-macro-quote# nvquote -t a"bcd" %%ef%% """gh"""i /* jk lm */ #if nopq #endif <!--rrrsssttt--> ## ////===================>press ctrl+D { "toks": [ { "type": 10, "raw": "a" }, { "type": 100, "lq": "\"", "rq": "\"", "q": "\"", "str": "bcd" }, { "type": 10, "raw": " " }, { "type": 100, "lq": "%%", "rq": "%%", "q": "%%", "str": "ef" }, { "type": 10, "raw": " " }, { "type": 100, "lq": "\"\"\"", "rq": "\"\"\"", "q": "\"\"\"", "str": "gh" }, { "type": 10, "raw": "i" }, { "q": "\n", "lq": "//", "rq": "\n", "type": 12 }, { "type": 100, "lq": "/*", "rq": "*/", "q": "/*", "str": "\njk\nlm\n" }, { "type": 10, "raw": " " }, { "type": 100, "lq": "#if", "rq": "#endif", "q": "#if", "str": " nopq " }, { "type": 10, "raw": " " }, { "type": 100, "lq": "<!--", "rq": "-->", "q": "<!--", "str": "rrrsssttt" }, { "q": "\n", "lq": "//", "rq": "\n", "type": 12 } ], "lefted": [ [], "##" ] }
- ISC