diff --git a/.changeset/stupid-worms-jam.md b/.changeset/stupid-worms-jam.md new file mode 100644 index 0000000..6ea2c98 --- /dev/null +++ b/.changeset/stupid-worms-jam.md @@ -0,0 +1,12 @@ +--- +"@codewars/marked-extensions": major +--- + +Clean up for v1 + +- Removed CM support. Utilize `highlight` function with CM directly if you wish to use this. +- Removed lineNumbers support, this may be added in later if a universal way of handling it is found +- Simplified extensions, loadScript support was removed, extensions need to load their own resources +- Removed Mermaid support, this can be added later as an external extension +- Upgraded `marked` from 0.6.2 to 2.1.1 and added to peer dependencies +- Removed `findLanguage` option, now just assumes anything unknown is a language diff --git a/package-lock.json b/package-lock.json index d00ffd3..b807fd0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6545,13 +6545,6 @@ "to-regex-range": "^5.0.1" } }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -8753,25 +8746,29 @@ "dependencies": { "abbrev": { "version": "1.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true, "optional": true }, "ansi-regex": { "version": "2.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true, "optional": true }, "aproba": { "version": "1.2.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true, "optional": true }, "are-we-there-yet": { "version": "1.1.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", "dev": true, "optional": true, "requires": { @@ -8781,13 +8778,15 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true, "optional": true }, "brace-expansion": { "version": "1.1.11", - "bundled": true, + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "optional": true, "requires": { @@ -8797,37 +8796,43 @@ }, "chownr": { "version": "1.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", "dev": true, "optional": true }, "code-point-at": { "version": "1.1.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true, "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true, "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "dev": true, "optional": true }, "core-util-is": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true, "optional": true }, "debug": { "version": "2.6.9", - "bundled": true, + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "optional": true, "requires": { @@ -8836,25 +8841,29 @@ }, "deep-extend": { "version": "0.6.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "dev": true, "optional": true }, "delegates": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "dev": true, "optional": true }, "detect-libc": { "version": "1.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", "dev": true, "optional": true }, "fs-minipass": { "version": "1.2.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", + "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "dev": true, "optional": true, "requires": { @@ -8863,13 +8872,15 @@ }, "fs.realpath": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true, "optional": true }, "gauge": { "version": "2.7.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "dev": true, "optional": true, "requires": { @@ -8885,7 +8896,8 @@ }, "glob": { "version": "7.1.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "optional": true, "requires": { @@ -8899,13 +8911,15 @@ }, "has-unicode": { "version": "2.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "dev": true, "optional": true }, "iconv-lite": { "version": "0.4.24", - "bundled": true, + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, "optional": true, "requires": { @@ -8914,7 +8928,8 @@ }, "ignore-walk": { "version": "3.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", "dev": true, "optional": true, "requires": { @@ -8923,7 +8938,8 @@ }, "inflight": { "version": "1.0.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "optional": true, "requires": { @@ -8933,19 +8949,22 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true, "optional": true }, "ini": { "version": "1.3.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true, "optional": true }, "is-fullwidth-code-point": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "optional": true, "requires": { @@ -8954,13 +8973,15 @@ }, "isarray": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true, "optional": true }, "minimatch": { "version": "3.0.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "optional": true, "requires": { @@ -8969,13 +8990,15 @@ }, "minimist": { "version": "0.0.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true, "optional": true }, "minipass": { "version": "2.3.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, "optional": true, "requires": { @@ -8985,7 +9008,8 @@ }, "minizlib": { "version": "1.2.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", "dev": true, "optional": true, "requires": { @@ -8994,7 +9018,8 @@ }, "mkdirp": { "version": "0.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "optional": true, "requires": { @@ -9003,13 +9028,15 @@ }, "ms": { "version": "2.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true, "optional": true }, "needle": { "version": "2.2.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", + "integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", "dev": true, "optional": true, "requires": { @@ -9020,7 +9047,8 @@ }, "node-pre-gyp": { "version": "0.10.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz", + "integrity": "sha512-d1xFs+C/IPS8Id0qPTZ4bUT8wWryfR/OzzAFxweG+uLN85oPzyo2Iw6bVlLQ/JOdgNonXLCoRyqDzDWq4iw72A==", "dev": true, "optional": true, "requires": { @@ -9038,7 +9066,8 @@ }, "nopt": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "dev": true, "optional": true, "requires": { @@ -9048,13 +9077,15 @@ }, "npm-bundled": { "version": "1.0.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz", + "integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==", "dev": true, "optional": true }, "npm-packlist": { "version": "1.2.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.2.0.tgz", + "integrity": "sha512-7Mni4Z8Xkx0/oegoqlcao/JpPCPEMtUvsmB0q7mgvlMinykJLSRTYuFqoQLYgGY8biuxIeiHO+QNJKbCfljewQ==", "dev": true, "optional": true, "requires": { @@ -9064,7 +9095,8 @@ }, "npmlog": { "version": "4.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "dev": true, "optional": true, "requires": { @@ -9076,19 +9108,22 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true, "optional": true }, "object-assign": { "version": "4.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true, "optional": true }, "once": { "version": "1.4.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "optional": true, "requires": { @@ -9097,19 +9132,22 @@ }, "os-homedir": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true, "optional": true }, "os-tmpdir": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true, "optional": true }, "osenv": { "version": "0.1.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "dev": true, "optional": true, "requires": { @@ -9119,19 +9157,22 @@ }, "path-is-absolute": { "version": "1.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true, "optional": true }, "process-nextick-args": { "version": "2.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true, "optional": true }, "rc": { "version": "1.2.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", "dev": true, "optional": true, "requires": { @@ -9143,7 +9184,8 @@ "dependencies": { "minimist": { "version": "1.2.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true, "optional": true } @@ -9151,7 +9193,8 @@ }, "readable-stream": { "version": "2.3.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "optional": true, "requires": { @@ -9166,7 +9209,8 @@ }, "rimraf": { "version": "2.6.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "dev": true, "optional": true, "requires": { @@ -9175,43 +9219,50 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true, "optional": true }, "safer-buffer": { "version": "2.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true, "optional": true }, "sax": { "version": "1.2.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true, "optional": true }, "semver": { "version": "5.6.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true, "optional": true }, "set-blocking": { "version": "2.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true, "optional": true }, "signal-exit": { "version": "3.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true, "optional": true }, "string-width": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "optional": true, "requires": { @@ -9222,7 +9273,8 @@ }, "string_decoder": { "version": "1.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "optional": true, "requires": { @@ -9231,7 +9283,8 @@ }, "strip-ansi": { "version": "3.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "optional": true, "requires": { @@ -9240,13 +9293,15 @@ }, "strip-json-comments": { "version": "2.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true, "optional": true }, "tar": { "version": "4.4.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", + "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", "dev": true, "optional": true, "requires": { @@ -9261,13 +9316,15 @@ }, "util-deprecate": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true, "optional": true }, "wide-align": { "version": "1.1.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", "dev": true, "optional": true, "requires": { @@ -9276,13 +9333,15 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true, "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", "dev": true, "optional": true } @@ -9452,12 +9511,6 @@ } } }, - "codemirror": { - "version": "5.39.0", - "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.39.0.tgz", - "integrity": "sha512-vpJRray/0ZCt9FiS7UcVr1JAm6OBdUt6TA/94Q7MScr8TnutVdQWh/WPr0migzaBPQmYvY7I9UZNvbsaLESIuQ==", - "dev": true - }, "collect-v8-coverage": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", @@ -16577,9 +16630,9 @@ } }, "marked": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.6.2.tgz", - "integrity": "sha512-LqxwVH3P/rqKX4EKGz7+c2G9r98WeM/SW34ybhgNGhUQNKtf1GmmSkJ6cDGJ/t6tiyae49qRkpyTw2B9HOrgUA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz", + "integrity": "sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==", "dev": true }, "md5.js": { @@ -19545,15 +19598,6 @@ "dev": true, "requires": { "fsevents": "~2.3.2" - }, - "dependencies": { - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - } } }, "rsvp": { diff --git a/package.json b/package.json index c1b2ecd..a2f1c5b 100755 --- a/package.json +++ b/package.json @@ -23,6 +23,9 @@ }, "keywords": [], "homepage": "https://github.com/codewars/marked-extensions", + "peerDependencies": { + "marked": "2.x" + }, "devDependencies": { "@babel/core": "^7.15.8", "@babel/preset-env": "^7.15.8", @@ -31,11 +34,10 @@ "@rollup/plugin-node-resolve": "^13.0.4", "babel-jest": "^27.3.1", "chai": "^3.5.0", - "codemirror": "^5.25.2", "jest": "^25.5.4", "jest-environment-jsdom": "^27.3.1", "js-yaml": "^3.10.0", - "marked": "^0.6.2", + "marked": "^2.1.1", "parcel-bundler": "^1.12.3", "rollup": "^2.56.2" }, diff --git a/src/index.js b/src/index.js index 80d2a59..09576f7 100644 --- a/src/index.js +++ b/src/index.js @@ -5,26 +5,21 @@ import { processDocTokens } from './doc-tokens' export const defaultOptions = { // these are the options passed to marked directly marked: {}, - // languages that should be treated as extensions. You can configure how each gets handled - extensions: { - mermaid: { - // code handler - code: code => `
${code}
`, - // will lazy load script automatically - src: 'https://cdn.rawgit.com/knsv/mermaid/6.0.0/dist/mermaid.min.js', - afterRender: () => window.mermaid && window.mermaid.init() - }, - }, - // set to a method that that will receive a language and return the mapped - // name. if no name is returned, it is assumed that the language is an extension. - // The default method only handles a default set of languages. - findLanguage: (language) => defaultLanguages.indexOf(language) >= 0 ? language: null, - - // used with CodeMirror.runMode, used to find the mode of the language. By default will just return the language - findMode: (language) => language, - - // The highlight theme to add, only used with cm runMode - theme: 'neo', + /** + * block extensions can be configured here. + * i.e. ```%mermaid block could be configured as + * extensions: { + * mermaid: { + * code (code, options) { + * // transform code + * }, + * afterRender () { + * // called after the markdown has rendered + * } + * } + * } + */ + extensions: {}, // you can set icons within headers using icon::ICONNAME, this setting determines the icon class prefix used iconClassPrefix: 'icon-', @@ -43,45 +38,13 @@ export const defaultOptions = { // setting will default the language to the first one found within the markdown. defaultLanguageToFirst: true, - // true if line numbers should be added to highlighted code (if a starting line number is configured for the block) - lineNumbers: true, - - // css class used to display a line number gutter, which can be used to try to create an opacity layer - // which will style the cm-number values differently. Set to null to disable adding a gutter. - lineNumbersGutter: 'cm-runmode-linenumbers-gutter', - // true if doc tokens should be parsed docTokens: true, // if set to an instance of js-yaml, it will process meta data at the top of the markdown. jsYaml: null, - - // If set to CodeMirror class, it will use CodeMirror.runMode to process syntax highlighting - // Note: make sure to import codemirror/addon/runmode/runmode.js first. - cm: null, - - // set to automatically load a CM language. This is provided by default but you can override if you wish - // to override. This option is only used if both cm and loadScript are set. - // You can set this to null if you do not wish or need to load languages dynamically - loadCMLanguage: (language, options) => { - return options.loadScript(`//cdnjs.cloudflare.com/ajax/libs/codemirror/${options.cm.version}/mode/${language}/${language}.min.js`); - }, - - // If you wish to support loading external extension scripts, you should set this to a - // function that takes a url and returns a promise. Note that this function will need to be responsible - // for not reloading the same scripts if requested more than once, this library does not take care of caching. - loadScript: null, - - // if set to a function, will be called back after all external scripts have loaded - onLoaded: null }; -export const defaultLanguages = [ - 'c', 'clojure', 'coffeescript', 'cpp', 'csharp', 'elixir', 'erlang', 'fsharp', - 'go', 'groovy', 'haskell', 'java', 'javascript', 'kotlin', 'objc', 'ocaml', 'php', 'python', - 'r', 'ruby', 'scala', 'shell', 'solidity', 'sql', 'swift', 'typescript' -] - /** * Processes the markdown using marked along with the many extensions this library provides * @param marked The marked library, must be passed in since it is not included within this library as a dependency @@ -123,10 +86,6 @@ export function process(marked, markdown, options = {}) { ['languages', 'extensions', 'icons'] .forEach(key => result[key] = Object.keys(result[key])); - if (options.loadScript) { - processExternalScripts(options, result); - } - return result; } @@ -158,41 +117,6 @@ function afterRenderFn(options, result) { } } -/** - * Will loop through extensions and languages and try to dynamically load scripts. - * @param options - * @param result - */ -function processExternalScripts(options, result) { - const promises = []; - result.extensions.forEach(ext => { - const config = options.extensions[ext]; - if (config && config.src) { - promises.push(options.loadScript(config.src)); - } - }); - - // automatically load the CM language that is shown - if (options.cm && options.loadCMLanguage) { - // if we filter languages then we only need to load the one being shown - if (options.filterLanguages && result.language) { - promises.push(options.loadCMLanguage(result.language, options)); - } - // otherwise we need to load them all - else if (!options.filterLanguages && result.languages.length) { - result.languages.forEach(language => { - promises.push(options.loadCMLanguage(language, options)); - }); - } - } - - Promise.all(promises).then(() => { - if (options.onLoaded) { - options.onLoaded(result); - } - }); -} - /** * Processes yaml content at the top of the markdown, marked starting by a --- and ending with a ... * @param options @@ -241,10 +165,7 @@ function processBlocks(options, result) { result.extensions[name] = true; } else { - const language = options.findLanguage(name); - if (language) { - result.languages[language] = true; - } + result.languages[name] = true; } } }) diff --git a/src/renderer.js b/src/renderer.js index 9ba3980..8946454 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -3,8 +3,6 @@ import { processDocTokens } from './doc-tokens' import { methodDoc } from './method-doc'; import { tableDoc } from './table-doc'; - - export function buildRenderer(marked, options, result) { const renderer = result.renderer = new marked.Renderer(); @@ -75,11 +73,8 @@ function setupCode(options, result) { else if (language.match(/^if-not:/)) { return matchIfBlockLanguage(result, language) ? '' : render(code); } - else if (language.match(/^tab:/)) { - return handleTab(result, code, language); - } else if (result.extensions.indexOf(language) >= 0) { - return handleExtension(options, result, code, language); + return handleExtension(options, code, language); } else if (language === '%definitions' || language === '%doc') { return wrapInBlockDiv(language, renderDefinitions(result, code, render)); @@ -87,30 +82,21 @@ function setupCode(options, result) { else if (language === '%method-doc') { return wrapInBlockDiv('docs method-doc', render(methodDoc(code, result.originalLanguage))); } - else if(language === '%table-doc') { + else if (language === '%table-doc') { return wrapInBlockDiv('docs table-doc', tableDoc(code)) - } - else if (language[0] === '%') { + } + else if (language[ 0 ] === '%') { return wrapInBlockDiv(language, result.render(code)); - } + } - // make sure this is a language and not some random tag - const foundLanguage = options.findLanguage(language.split(':')[0]); + // at this point just assume that whatever is left is a language that needs to be formatted + const codeLanguage = language.split(':')[0] - if (foundLanguage) { + if (codeLanguage) { // if filtering is enabled and this is not the active language then filter it out - if (options.filterLanguages && foundLanguage !== result.language && result.language) { + if (options.filterLanguages && codeLanguage !== result.language && result.language) { return ''; } - - // if CodeMirror is provided then highlight using that instead - if (options.cm) { - return highlightCM(options, code, foundLanguage, language); - } - } - // process line numbers, if they are set (i.e. ruby:10) in a naive simple way - else if (options.lineNumbers) { - code = lineNumbers(code, language); } } @@ -118,19 +104,6 @@ function setupCode(options, result) { } } -function lineNumbers(code, language, wrapper = '@@ ') { - let lineNumber = getLineNumber(language); - - // if there are line numbers, then add them now starting at the start index - if (lineNumber > 0) { - code = code.split('\n').map(line => { - return `${wrapper.replace('@@', lineNumber++)}${line}` - }).join('\n'); - } - - return code; -} - function wrapLanguage(options, code, language) { // if we have reached this point then CM isn't enabled and we need to if (language && options.languageWrapper) { @@ -145,24 +118,6 @@ function wrapLanguage(options, code, language) { return code; } -function highlightCM(options, code, language, raw) { - const el = window.document.createElement('div'); - options.cm.runMode(code, options.findMode(language), el); - - let codeHtml = el.innerHTML; - if (options.lineNumbers) { - codeHtml = lineNumbers(codeHtml, raw, '@@'); - } - - const result = `
${codeHtml}
`; - return wrapLanguage(options, result, language); -} - -function getLineNumber(language) { - const parts = language.split(':'); - return parts.length > 1 ? parseInt(parts[1], 10) : null; -} - function wrapInBlockDiv(type, contents) { return `
${contents}
`; } @@ -171,14 +126,6 @@ function matchIfBlockLanguage(result, language) { return language.replace(/^if(-not)?: ?/, '').split(',').indexOf(result.originalLanguage) >= 0; } -function handleTab(result, code, language) { - // parts should be up to tab:LABEL with language being optional - const parts = language.split(':'); - let label = parts[1].replace(/\+/g, ' '); - result.tabs[label] = `${result.render(code)}`; - return ''; -} - /** * If the extension value is a function, it will treat it as a render function, otherwise it will * assume the extension value is a string and treat it as a template with {code} as the code placeholder. @@ -186,7 +133,7 @@ function handleTab(result, code, language) { * @param code * @param language */ -function handleExtension(options, result, code, language) { +function handleExtension(options, code, language) { const ext = options.extensions[language] if (typeof ext.code === 'function') { diff --git a/test/fixtures/mermaid.md b/test/fixtures/extensions.md similarity index 100% rename from test/fixtures/mermaid.md rename to test/fixtures/extensions.md diff --git a/test/index.spec.js b/test/index.spec.js index 0009c46..7988f5c 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -5,9 +5,6 @@ import { expect } from 'chai' import { fixture } from './test-utils' import { escapeHtml } from '../src/strings' -const CodeMirror = require('codemirror/lib/codemirror'); -require('codemirror/addon/runmode/runmode.js'); - describe('process', function() { const basicExample = process(marked, fixture('basic')); @@ -71,46 +68,6 @@ describe('process', function() { }); }); - describe('CodeMirror', function() { - const cmBasicExample = process(marked, fixture('basic'), {cm: CodeMirror}); - - // const cmNoNumberedExample = process(marked, fixture('numbered'), {cm: CodeMirror, lineNumbers: false}); - // const cmNumberedNoGutterExample = process(marked, fixture('numbered'), {cm: CodeMirror, lineNumbersGutter: true}); - - it('should return a valid object', function() { - expect(cmBasicExample).to.be.an('object'); - }); - - it('should include theme within content', function() { - expect(cmBasicExample.html()).to.include('neo'); - }); - - // CM is not behaving within mocha/jsdom so we are skipping for now - it.skip ('should include highlighted cm spans', function() { - expect(cmBasicExample.html()).to.include('cm-variable'); - }); - - describe('line numbers', function() { - it('should include line number wrapper when CM used', function() { - const example = process(marked, fixture('numbered'), {lineNumbers: true, cm: CodeMirror}); - expect(example.html()).to.include('9'); - }); - }); - - it('should load language files', function() { - const loaded = []; - const load = url => { - loaded.push(url); - return Promise.resolve(); - }; - - const example = process(marked, fixture('basic'), {cm: CodeMirror, loadScript: load}); - - expect(loaded.length).to.equal(1); - expect(loaded[0]).to.contain('mode/javascript/javascript.min.js'); - }); - }); - describe('Docs', function() { it('should process javascript', function() { @@ -174,27 +131,22 @@ describe('process', function() { }); }); - describe('mermaid', function() { + describe('extensions', function() { + const extensions = { + mermaid: { + code: code => `
${ code }
` + } + } + it('should add html wrapper', function() { - let example = process(marked, fixture('mermaid'), {language: 'javascript'}); + let example = process(marked, fixture('extensions'), { extensions }); expect(example.html()).to.include('
'); }); it('should detect as an extension', function() { - let example = process(marked, fixture('mermaid'), {language: 'javascript'}); + let example = process(marked, fixture('extensions'), { extensions }); expect(example.extensions[0]).to.equal('mermaid'); }); - - it('should load script if loader is provided', function() { - const loaded = []; - const load = url => { - loaded.push(url); - return Promise.resolve(); - }; - let example = process(marked, fixture('mermaid'), {language: 'javascript', loadScript: load}); - expect(loaded.length).to.equal(1); - expect(loaded[0]).to.contain('mermaid'); - }); }); describe('languageWrapper', function() {