square-quotes
Because the world needs one more way of quoting strings.
I wrote this for flextags, which needs quoting that doesn't seem like "people" are being "cautious" with their "wording", and for use by people who don't understand backslash-escaping.
But it might also be useful more broadly, when escaping gets confusing. (Ironically, this code internally is a nightmare of escaping backslashes.)
There's a fundamental result in computer science that finite automata, like regular expression engines, can't do balancing of parentheses. However, they can handle balancing parens N levels deep for compile-time N. So at the moment this is implemented with a big regexp.
Converting from square quotes to normal quotes
Input
line before square brackets[Square brackets workacross newlineswith "quotes" and escaped \"quotes\"and [with [nested [bracket [expressions]]]]] appended textlast line
Command line:
$ convert-from-square-quotes <sample.txtline before square brackets"\nSquare brackets work\nacross newlines\nwith \"quotes\" and escaped \\\"quotes\\\"\nand [with [nested [bracket [expressions]]]]\n" appended textlast line
In code:
const sq = console// => Some "text" using "various" quotation "[styles]".
Wrapping in square quotes (aka brackets)
const sq = console// => ["hello!"] console// => [[a]] console// => "[a" fall back to normal quotes if necessary