This package has been deprecated

Author message:

improved-and-integrated-into-nvlang-user-defined-dsl-feature-this-is-useless-now

nv-macro-quote

1.0.7 • Public • Published

nv-macro-quote

  • nv-macro-quote
  • cli tool, unquote mixed-quoted string

install

  • npm install nv-macro-quote -g

usage

    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

dflt supported quotes

    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#

example

    //string-for-test:

    `
    a"bcd" %%ef%% """gh"""i
    /*
    jk
    lm
    */  #if nopq #endif  <!--rrrsssttt-->
    ##
    `

output str-without-quote

    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": [
            [],
            "##"
        ]
    }

output str-with-quote

    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#

output array

  • 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": [
              [],
              "##"
          ]
      }
    

output toks

  • 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": [
              [],
              "##"
          ]
      }
    

LICENSE

  • ISC

Readme

Keywords

none

Package Sidebar

Install

npm i nv-macro-quote

Weekly Downloads

0

Version

1.0.7

License

ISC

Unpacked Size

12.1 kB

Total Files

3

Last publish

Collaborators

  • ihgazni2