FlatLang / Flat

(Deprecated) Soon-to-be legacy Flat compiler all in one
6 stars 0 forks source link

Handle multi-quote string literals that auto-escapes double quotes #419

Open BSteffaniak opened 2 years ago

BSteffaniak commented 2 years ago
let jsonContents = "|
  {
    \"name\": \"#name\",
    \"version\": \"#version\",
    \"description\": \"#description\",
    \"author\": \"#author\",
    \"license\": \"#license\",
    \"defaultTarget\": \"#defaultTarget\",
    \"scripts\": {
      \"test\": \"node dist/test.js\"
    },
    \"main\": {
      #mainClassProperty\"source\": \"src\",
      \"dependencies\": {
      }
    },
    \"test\": {
      #testMainClassProperty\"source\": \"src\",
      \"dependencies\": {
        \"github:FlatLang/Nest\": \"master\"
      }
    }
  }\n
  |"

can be written as:

let jsonContents = """|
  {
    "name": "#name",
    "version": "#version",
    "description": "#description",
    "author": "#author",
    "license": "#license",
    "defaultTarget": "#defaultTarget",
    "scripts": {
      "test": "node dist/test.js"
    },
    "main": {
      #mainClassProperty"source": "src",
      "dependencies": {
      }
    },
    "test": {
      #testMainClassProperty"source": "src",
      "dependencies": {
        "github:FlatLang/Nest": "master"
      }
    }
  }\n
  |"""
BSteffaniak commented 2 years ago

Handle any amount of quotes (except for 2), as long as the start and end quote count match. e.g.:

"test" """test""" """""""""test""""""""" etc...