diff --git a/babel.config.js b/babel.config.js index a6bce35..a22e780 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,4 +1,9 @@ module.exports = { presets: ['@babel/preset-env'], - plugins: ['@babel/plugin-transform-runtime'] + ignore: ['**/*.spec.js', '**/*.test.js'], + plugins: [ + '@babel/plugin-transform-runtime', + '@babel/plugin-transform-modules-commonjs' + ], + sourceMaps: 'both' } diff --git a/package-lock.json b/package-lock.json index a2a2bb5..d022739 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3,6 +3,41 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/cli": { + "version": "7.11.6", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.11.6.tgz", + "integrity": "sha512-+w7BZCvkewSmaRM6H4L2QM3RL90teqEIHDIFXAmrW33+0jhlymnDAEdqVeCZATvxhQuio1ifoGVlJJbIiH9Ffg==", + "dev": true, + "requires": { + "chokidar": "^2.1.8", + "commander": "^4.0.1", + "convert-source-map": "^1.1.0", + "fs-readdir-recursive": "^1.1.0", + "glob": "^7.0.0", + "lodash": "^4.17.19", + "make-dir": "^2.1.0", + "slash": "^2.0.0", + "source-map": "^0.5.0" + }, + "dependencies": { + "make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "requires": { + "pify": "^4.0.1", + "semver": "^5.6.0" + } + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + } + } + }, "@babel/code-frame": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", @@ -3333,6 +3368,13 @@ "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, + "async-each": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", + "dev": true, + "optional": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -3575,6 +3617,13 @@ "integrity": "sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==", "dev": true }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", + "dev": true, + "optional": true + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -3823,6 +3872,193 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, + "chokidar": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", + "dev": true, + "optional": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + }, + "dependencies": { + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "optional": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "optional": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "optional": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "optional": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "optional": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "optional": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "dev": true, + "optional": true + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "dev": true, + "optional": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "optional": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "optional": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "optional": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "optional": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "optional": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + } + } + }, "chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", @@ -4015,6 +4251,12 @@ "integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==", "dev": true }, + "commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true + }, "compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -4627,6 +4869,15 @@ } } }, + "cross-env": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.2.tgz", + "integrity": "sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.1" + } + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -5953,6 +6204,12 @@ "minipass": "^2.6.0" } }, + "fs-readdir-recursive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", + "integrity": "sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==", + "dev": true + }, "fs-write-stream-atomic": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", @@ -7323,6 +7580,16 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "optional": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", @@ -10723,6 +10990,131 @@ "once": "^1.3.0" } }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "dev": true, + "optional": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + }, + "dependencies": { + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "optional": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "optional": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "optional": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "optional": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "optional": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "optional": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "optional": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "optional": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + } + } + }, "redent": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", diff --git a/package.json b/package.json index 205ef18..7576ec8 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,10 @@ "release": "lerna version --create-release github --conventional-commits --yes && lerna publish from-package --yes" }, "devDependencies": { + "@babel/cli": "^7.11.6", + "@babel/plugin-transform-modules-commonjs": "^7.10.4", "@babel/plugin-transform-runtime": "^7.11.0", + "cross-env": "^7.0.2", "dedent": "^0.7.0", "eslint": "^7.7.0", "eslint-config-prettier": "^6.11.0", @@ -26,7 +29,7 @@ "remark-html": "^12.0.0" }, "dependencies": { - "@babel/core": "^7.11.4", + "@babel/core": "^7.11.6", "@babel/preset-env": "^7.11.0", "@babel/runtime": "^7.11.2", "regenerator-runtime": "^0.13.7" diff --git a/packages/ggsmark/package.json b/packages/ggsmark/package.json index e3dbe1b..08094c6 100644 --- a/packages/ggsmark/package.json +++ b/packages/ggsmark/package.json @@ -17,5 +17,9 @@ "remark-spoilers": "^0.1.1", "remark-text-alignment": "^0.2.4", "unified": "^9.2.0" + }, + "main": "dist/index.js", + "scripts": { + "build": "cross-env BABEL_ENV=production babel index.js --config-file ../../babel.config.js --out-dir ./dist" } } diff --git a/packages/remark-color-text/index.js b/packages/remark-color-text/index.js index 945df34..010a609 100644 --- a/packages/remark-color-text/index.js +++ b/packages/remark-color-text/index.js @@ -1,146 +1,136 @@ -const C_NEWLINE = '\n' -const C_NEWPARAGRAPH = '\n\n' - +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = plugin; +var C_NEWLINE = '\n'; +var C_NEWPARAGRAPH = '\n\n'; /** * Match line against an array of token * @param {String} token token like '!#' * @param {String} value value to check of the token */ + function matchToken(token, value) { - return value.trim().startsWith(token) + return value.trim().startsWith(token); } - /** * Get the color of a block * @param {String} token token like '!#' * @param {String} colorExpression regular expression to match, it must capture the first group * @param {String} block final string block to be parsed */ + + function getBlockColor(token, colorExpression, block) { - let trimmedBlock = block.trim() + var trimmedBlock = block.trim(); + if (trimmedBlock.startsWith(token)) { - return trimmedBlock.slice(token.length).match(colorExpression)[1] + return trimmedBlock.slice(token.length).match(colorExpression)[1]; } } -export default function plugin(options = {}) { - const Parser = this.Parser - const blockTokenizers = Parser.prototype.blockTokenizers - const blockMethods = Parser.prototype.blockMethods - const inlineTokenizers = Parser.prototype.inlineTokenizers - const inlineMethods = Parser.prototype.inlineMethods +function plugin() { + var _options$token, _options$colorExpress; - options.token = options.token ?? '!#' - options.colorExpression = - options.colorExpression ?? - /^\s*(rgba?\(\d{1,3}\s*\,\s*\d{1,3}\s*\,\s*\d{1,3}\s*(\,\s*\d{1,3}\s*)?\)|(\#?[A-z0-9]{3,12}))?/ + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var Parser = this.Parser; + var blockTokenizers = Parser.prototype.blockTokenizers; + var blockMethods = Parser.prototype.blockMethods; + var inlineTokenizers = Parser.prototype.inlineTokenizers; + var inlineMethods = Parser.prototype.inlineMethods; + options.token = (_options$token = options.token) !== null && _options$token !== void 0 ? _options$token : '!#'; + options.colorExpression = (_options$colorExpress = options.colorExpression) !== null && _options$colorExpress !== void 0 ? _options$colorExpress : /^\s*(rgba?\(\d{1,3}\s*\,\s*\d{1,3}\s*\,\s*\d{1,3}\s*(\,\s*\d{1,3}\s*)?\)|(\#?[A-z0-9]{3,12}))?/; function tokenizeBlocks(eat, value, silent) { - let match = matchToken(options.token, value) - - if (!match) return - - if (silent) return true - - let startBlock, - endBlock = 0 - let index, - newLine = 0 - let completeBlock = false - let firstRun = true + var match = matchToken(options.token, value); + if (!match) return; + if (silent) return true; + var startBlock, + endBlock = 0; + var index, + newLine = 0; + var completeBlock = false; + var firstRun = true; do { - newLine = value.indexOf(C_NEWLINE, index + 1) + newLine = value.indexOf(C_NEWLINE, index + 1); + var line = value.substring(index, newLine === -1 ? value.length : newLine); + var matchedEndToken = matchToken(options.token, line) && !firstRun; // Found a match to end the block - let line = value.substring(index, newLine === -1 ? value.length : newLine) - let matchedEndToken = matchToken(options.token, line) && !firstRun - - // Found a match to end the block if (!!matchedEndToken) { - endBlock = newLine === -1 ? value.length : newLine - completeBlock = true + endBlock = newLine === -1 ? value.length : newLine; + completeBlock = true; } - index = newLine - firstRun = false - } while (!completeBlock && newLine !== -1) - - if (!completeBlock) return - - let block = value.substring(startBlock, endBlock) - let blockContent = block - .substring(block.indexOf(C_NEWLINE), block.lastIndexOf(C_NEWLINE)) - .trim() - - let color = getBlockColor(options.token, options.colorExpression, block) - - const start = eat.now() - const add = eat(block) - const end = eat.now() - const children = this.tokenizeBlock(blockContent, start) - + index = newLine; + firstRun = false; + } while (!completeBlock && newLine !== -1); + + if (!completeBlock) return; + var block = value.substring(startBlock, endBlock); + var blockContent = block.substring(block.indexOf(C_NEWLINE), block.lastIndexOf(C_NEWLINE)).trim(); + var color = getBlockColor(options.token, options.colorExpression, block); + var start = eat.now(); + var add = eat(block); + var end = eat.now(); + var children = this.tokenizeBlock(blockContent, start); return add({ type: 'colorText', children: children, data: { hName: 'div', hProperties: { - style: `color: ${color}` + style: "color: ".concat(color) } }, position: { - start, - end + start: start, + end: end } - }) + }); } function locateInlineToken(value, fromIndex) { - return value.indexOf(options.token, fromIndex) + return value.indexOf(options.token, fromIndex); } function tokenizeInlines(eat, value, silent) { - let match = matchToken(options.token, value) - - if (!match) return - - if (silent) return true - - let color = getBlockColor(options.token, options.colorExpression, value) - let openBracket = value.indexOf('(') + 1 - let closeBracket = value.indexOf(')') - let inline = value.substring(0, closeBracket + 1) - let inlineContent = value.substring(openBracket, closeBracket) - - if (openBracket === -1 || closeBracket === -1) return - - const start = eat.now() - const add = eat(inline) - const end = eat.now() - const children = this.tokenizeInline(inlineContent, start) - + var match = matchToken(options.token, value); + if (!match) return; + if (silent) return true; + var color = getBlockColor(options.token, options.colorExpression, value); + var openBracket = value.indexOf('(') + 1; + var closeBracket = value.indexOf(')'); + var inline = value.substring(0, closeBracket + 1); + var inlineContent = value.substring(openBracket, closeBracket); + if (openBracket === -1 || closeBracket === -1) return; + var start = eat.now(); + var add = eat(inline); + var end = eat.now(); + var children = this.tokenizeInline(inlineContent, start); return add({ type: 'colorText', children: children, data: { hName: 'span', hProperties: { - style: `color: ${color}` + style: "color: ".concat(color) } }, position: { - start, - end + start: start, + end: end } - }) + }); } - tokenizeInlines.notInLink = true - tokenizeInlines.locator = locateInlineToken - - blockTokenizers.colorText = tokenizeBlocks - inlineTokenizers.colorText = tokenizeInlines - - blockMethods.splice(blockMethods.indexOf('blockquote') + 1, 0, 'colorText') - inlineMethods.splice(inlineMethods.indexOf('escape') + 1, 0, 'colorText') + tokenizeInlines.notInLink = true; + tokenizeInlines.locator = locateInlineToken; + blockTokenizers.colorText = tokenizeBlocks; + inlineTokenizers.colorText = tokenizeInlines; + blockMethods.splice(blockMethods.indexOf('blockquote') + 1, 0, 'colorText'); + inlineMethods.splice(inlineMethods.indexOf('escape') + 1, 0, 'colorText'); } +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbIk9iamVjdCIsInZhbHVlIiwiZXhwb3J0cyIsIkNfTkVXTElORSIsIkNfTkVXUEFSQUdSQVBIIiwidHJpbW1lZEJsb2NrIiwiYmxvY2siLCJ0b2tlbiIsIm9wdGlvbnMiLCJhcmd1bWVudHMiLCJQYXJzZXIiLCJibG9ja1Rva2VuaXplcnMiLCJibG9ja01ldGhvZHMiLCJpbmxpbmVUb2tlbml6ZXJzIiwiaW5saW5lTWV0aG9kcyIsIl9vcHRpb25zJHRva2VuIiwiX29wdGlvbnMkY29sb3JFeHByZXNzIiwibWF0Y2giLCJtYXRjaFRva2VuIiwiZW5kQmxvY2siLCJuZXdMaW5lIiwiY29tcGxldGVCbG9jayIsImZpcnN0UnVuIiwiaW5kZXgiLCJsaW5lIiwibWF0Y2hlZEVuZFRva2VuIiwiYmxvY2tDb250ZW50IiwiY29sb3IiLCJnZXRCbG9ja0NvbG9yIiwic3RhcnQiLCJlYXQiLCJhZGQiLCJlbmQiLCJjaGlsZHJlbiIsInR5cGUiLCJkYXRhIiwiaE5hbWUiLCJoUHJvcGVydGllcyIsInN0eWxlIiwicG9zaXRpb24iLCJvcGVuQnJhY2tldCIsImNsb3NlQnJhY2tldCIsImlubGluZSIsImlubGluZUNvbnRlbnQiLCJ0b2tlbml6ZUlubGluZXMiXSwibWFwcGluZ3MiOiJBQUFBOztBQUVBQSxNQUFNLENBQU5BLGNBQUFBLENBQUFBLE9BQUFBLEVBQUFBLFlB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9jYXRlSW5saW5lVG9rZW47XG4gIGJsb2NrVG9rZW5pemVycy5jb2xvclRleHQgPSB0b2tlbml6ZUJsb2NrcztcbiAgaW5saW5lVG9rZW5pemVycy5jb2xvclRleHQgPSB0b2tlbml6ZUlubGluZXM7XG4gIGJsb2NrTWV0aG9kcy5zcGxpY2UoYmxvY2tNZXRob2RzLmluZGV4T2YoJ2Jsb2NrcXVvdGUnKSArIDEsIDAsICdjb2xvclRleHQnKTtcbiAgaW5saW5lTWV0aG9kcy5zcGxpY2UoaW5saW5lTWV0aG9kcy5pbmRleE9mKCdlc2NhcGUnKSArIDEsIDAsICdjb2xvclRleHQnKTtcbn0iXX0= \ No newline at end of file diff --git a/packages/remark-color-text/package.json b/packages/remark-color-text/package.json index ffd1431..9f19c97 100644 --- a/packages/remark-color-text/package.json +++ b/packages/remark-color-text/package.json @@ -5,5 +5,9 @@ "keywords": [ "remark" ], - "license": "MIT" + "license": "MIT", + "main": "dist/index.js", + "scripts": { + "build": "cross-env BABEL_ENV=production babel index.js --config-file ../../babel.config.js --out-dir ." + } } diff --git a/packages/remark-spoilers/package.json b/packages/remark-spoilers/package.json index 7fac64c..473a22f 100644 --- a/packages/remark-spoilers/package.json +++ b/packages/remark-spoilers/package.json @@ -5,5 +5,9 @@ "keywords": [ "remark" ], - "license": "MIT" + "license": "MIT", + "main": "dist/index.js", + "scripts": { + "build": "cross-env BABEL_ENV=production babel index.js --config-file ../../babel.config.js --out-dir ./dist" + } } diff --git a/packages/remark-text-alignment/package.json b/packages/remark-text-alignment/package.json index a000c54..b5fa5a8 100644 --- a/packages/remark-text-alignment/package.json +++ b/packages/remark-text-alignment/package.json @@ -8,5 +8,9 @@ "license": "MIT", "dependencies": { "space-separated-tokens": "^1.1.5" + }, + "main": "dist/index.js", + "scripts": { + "build": "cross-env BABEL_ENV=production babel index.js --config-file ../../babel.config.js --out-dir ./dist" } }