From ea17dcc66cd4bf3154afa16b38d357b2285c8f5e Mon Sep 17 00:00:00 2001 From: Tom Schaible Date: Thu, 2 Apr 2020 08:27:03 -0400 Subject: [PATCH 01/49] updated the insertion of embedded tokens so it correctly handles embedded token results returning in any order fixes #970 --- src/core/render/embed.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/core/render/embed.js b/src/core/render/embed.js index 083fb7f97..8c0cf5755 100644 --- a/src/core/render/embed.js +++ b/src/core/render/embed.js @@ -1,6 +1,6 @@ +import stripIndent from 'strip-indent'; import { get } from '../fetch/ajax'; import { merge } from '../util/core'; -import stripIndent from 'strip-indent'; const cached = {}; @@ -117,17 +117,27 @@ export function prerenderEmbed({ compiler, raw = '', fetch }, done) { } }); - let moveIndex = 0; + // keep track of which tokens have been embedded so far + // so that we know where to insert the embedded tokens as they + // are returned + const moves = []; walkFetchEmbed({ compile, embedTokens, fetch }, ({ embedToken, token }) => { if (token) { - const index = token.index + moveIndex; + // iterate through the array of previously inserted tokens + // to determine where the current embedded tokens should be inserted + let index = token.index; + moves.forEach(pos => { + if (index > pos.start) { + index += pos.length; + } + }); merge(links, embedToken.links); tokens = tokens .slice(0, index) .concat(embedToken, tokens.slice(index + 1)); - moveIndex += embedToken.length - 1; + moves.push({ start: index, length: embedToken.length - 1 }); } else { cached[raw] = tokens.concat(); tokens.links = cached[raw].links = links; From 96d5b19a96cef9dd48582594217d7cda0f61b060 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Thu, 9 Apr 2020 10:35:59 +0530 Subject: [PATCH 02/49] chore: update auto format config --- package-lock.json | 369 ++++++++++++++++++++-------------------------- package.json | 7 +- 2 files changed, 164 insertions(+), 212 deletions(-) diff --git a/package-lock.json b/package-lock.json index 58a81e284..e598bcd34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,6 +85,15 @@ "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", "dev": true }, + "@babel/runtime": { + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.9.2.tgz", + "integrity": "sha512-NE2DtOdufG7R5vnfQUTehdTfNycfUANEtCa9PssN9O/xmTzP4E08UI797ixaei6hBEVL9BI/PsdJS5x7mWoB9Q==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, "@babel/template": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", @@ -1517,40 +1526,12 @@ "glob-to-regexp": "^0.3.0" } }, - "@nodelib/fs.scandir": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", - "integrity": "sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "2.0.3", - "run-parallel": "^1.1.9" - }, - "dependencies": { - "@nodelib/fs.stat": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz", - "integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==", - "dev": true - } - } - }, "@nodelib/fs.stat": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz", "integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==", "dev": true }, - "@nodelib/fs.walk": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz", - "integrity": "sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==", - "dev": true, - "requires": { - "@nodelib/fs.scandir": "2.1.3", - "fastq": "^1.6.0" - } - }, "@octokit/endpoint": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-5.4.0.tgz", @@ -1655,6 +1636,12 @@ "any-observable": "^0.3.0" } }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -1696,6 +1683,12 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, + "@types/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", + "dev": true + }, "@types/q": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.2.tgz", @@ -1818,24 +1811,6 @@ "humanize-ms": "^1.2.1" } }, - "aggregate-error": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", - "integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==", - "dev": true, - "requires": { - "clean-stack": "^2.0.0", - "indent-string": "^4.0.0" - }, - "dependencies": { - "indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "dev": true - } - } - }, "ajv": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", @@ -2862,12 +2837,6 @@ } } }, - "clean-stack": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", - "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", - "dev": true - }, "cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", @@ -4378,111 +4347,6 @@ } } }, - "del": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/del/-/del-5.1.0.tgz", - "integrity": "sha512-wH9xOVHnczo9jN2IW68BabcecVPxacIA3g/7z6vhSU/4stOKQzeCRK0yD0A24WiAAUJmmVpWqrERcTxnLo3AnA==", - "dev": true, - "requires": { - "globby": "^10.0.1", - "graceful-fs": "^4.2.2", - "is-glob": "^4.0.1", - "is-path-cwd": "^2.2.0", - "is-path-inside": "^3.0.1", - "p-map": "^3.0.0", - "rimraf": "^3.0.0", - "slash": "^3.0.0" - }, - "dependencies": { - "@nodelib/fs.stat": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz", - "integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==", - "dev": true - }, - "array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true - }, - "dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "requires": { - "path-type": "^4.0.0" - } - }, - "fast-glob": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.1.1.tgz", - "integrity": "sha512-nTCREpBY8w8r+boyFYAx21iL6faSsQynliPHM4Uf56SbkyohCNxpVPEH9xrF5TXKy+IsjkPUHDKiUkzBVRXn9g==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.0", - "merge2": "^1.3.0", - "micromatch": "^4.0.2" - } - }, - "globby": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/globby/-/globby-10.0.1.tgz", - "integrity": "sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==", - "dev": true, - "requires": { - "@types/glob": "^7.1.1", - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.0.3", - "glob": "^7.1.3", - "ignore": "^5.1.1", - "merge2": "^1.2.3", - "slash": "^3.0.0" - } - }, - "ignore": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz", - "integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==", - "dev": true - }, - "micromatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", - "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", - "dev": true, - "requires": { - "braces": "^3.0.1", - "picomatch": "^2.0.5" - } - }, - "p-map": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", - "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", - "dev": true, - "requires": { - "aggregate-error": "^3.0.0" - } - }, - "path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true - }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true - } - } - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -5588,15 +5452,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "fastq": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.0.tgz", - "integrity": "sha512-jmxqQ3Z/nXoeyDmWAzF9kH1aGZSis6e/SbfPmJpUnyZ0ogr6iscHQaml4wsEepEWSdtmpy+eVXmCRIMpxaXqOA==", - "dev": true, - "requires": { - "reusify": "^1.0.0" - } - }, "faye-websocket": { "version": "0.11.3", "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.3.tgz", @@ -6744,6 +6599,12 @@ } } }, + "human-signals": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", + "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", + "dev": true + }, "humanize-ms": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", @@ -7261,18 +7122,6 @@ "symbol-observable": "^1.1.0" } }, - "is-path-cwd": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", - "integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==", - "dev": true - }, - "is-path-inside": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.2.tgz", - "integrity": "sha512-/2UGPSgmtqwo1ktx8NDHjuPwZWmHhO+gj0f93EkhLB5RgW9RZevWYYlIkS6zePc6U2WpOdQYIwHe9YC4DWEBVg==", - "dev": true - }, "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -7705,38 +7554,92 @@ "dev": true }, "lint-staged": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-9.5.0.tgz", - "integrity": "sha512-nawMob9cb/G1J98nb8v3VC/E8rcX1rryUYXVZ69aT9kde6YWX+uvNOEHY5yf2gcWcTJGiD0kqXmCnS3oD75GIA==", + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.1.2.tgz", + "integrity": "sha512-Vtbe8rhWbJxPNlnXk6jczRh6wvAVjGg+VhELAIjLakOjTACdB4qJOD4W2R8oUXLRCqL1t9WMUsXbSlVK34A8Lg==", "dev": true, "requires": { - "chalk": "^2.4.2", - "commander": "^2.20.0", - "cosmiconfig": "^5.2.1", + "chalk": "^3.0.0", + "commander": "^4.0.1", + "cosmiconfig": "^6.0.0", "debug": "^4.1.1", "dedent": "^0.7.0", - "del": "^5.0.0", - "execa": "^2.0.3", + "execa": "^3.4.0", "listr": "^0.14.3", "log-symbols": "^3.0.0", "micromatch": "^4.0.2", "normalize-path": "^3.0.0", - "please-upgrade-node": "^3.1.1", - "string-argv": "^0.3.0", + "please-upgrade-node": "^3.2.0", + "string-argv": "0.3.1", "stringify-object": "^3.3.0" }, "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "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 + }, + "cosmiconfig": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz", + "integrity": "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==", + "dev": true, + "requires": { + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.1.0", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.7.2" + } + }, "execa": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-2.1.0.tgz", - "integrity": "sha512-Y/URAVapfbYy2Xp/gb6A0E7iR8xeqOCXsuuaoMn7A5PzrXUK84E1gyiEfq0wQd/GHA6GsoHWwhNq8anb0mleIw==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-3.4.0.tgz", + "integrity": "sha512-r9vdGQk4bmCuK1yKQu1KTwcT2zwfWdbdaXfCtAh+5nU/4fSX+JAb7vZGvI5naJrQlvONrEB20jeruESI69530g==", "dev": true, "requires": { "cross-spawn": "^7.0.0", "get-stream": "^5.0.0", + "human-signals": "^1.1.1", "is-stream": "^2.0.0", "merge-stream": "^2.0.0", - "npm-run-path": "^3.0.0", + "npm-run-path": "^4.0.0", "onetime": "^5.1.0", "p-finally": "^2.0.0", "signal-exit": "^3.0.2", @@ -7752,6 +7655,22 @@ "pump": "^3.0.0" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "import-fresh": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, "is-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", @@ -7775,9 +7694,9 @@ "dev": true }, "npm-run-path": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-3.1.0.tgz", - "integrity": "sha512-Dbl4A/VfiVGLgQv29URL9xshU8XDY1GeLy+fsaZ1AA8JDSfjvr5P5+pzRbWqRSBxk6/DW7MIh8lTM/PaGnP2kg==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", "dev": true, "requires": { "path-key": "^3.0.0" @@ -7797,6 +7716,39 @@ "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-2.0.1.tgz", "integrity": "sha512-vpm09aKwq6H9phqRQzecoDpD8TmVyGw70qmWlyq5onxY7tqyTTFVvxMykxQSQKILBSFlbXpypIw2T1Ml7+DDtw==", "dev": true + }, + "parse-json": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", + "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1", + "lines-and-columns": "^1.1.6" + } + }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } } } }, @@ -11499,6 +11451,12 @@ "regenerate": "^1.4.0" } }, + "regenerator-runtime": { + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", + "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==", + "dev": true + }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", @@ -11722,12 +11680,6 @@ "integrity": "sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q=", "dev": true }, - "reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true - }, "rgb-regex": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/rgb-regex/-/rgb-regex-1.0.1.tgz", @@ -11947,12 +11899,6 @@ "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==", "dev": true }, - "run-parallel": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", - "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==", - "dev": true - }, "run-queue": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", @@ -14012,6 +13958,15 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true }, + "yaml": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.8.3.tgz", + "integrity": "sha512-X/v7VDnK+sxbQ2Imq4Jt2PRUsRsP7UcpSl3Llg6+NRRqWLIvxkMFYtH1FmvwNGYRKKPa+EPA4qDBlI9WVG1UKw==", + "dev": true, + "requires": { + "@babel/runtime": "^7.8.7" + } + }, "yargs": { "version": "12.0.5", "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", diff --git a/package.json b/package.json index 695e960fc..9e0b0a115 100644 --- a/package.json +++ b/package.json @@ -54,10 +54,7 @@ } }, "lint-staged": { - "*.js": [ - "npm run fixlint", - "git add" - ] + "*.js": "eslint --fix" }, "dependencies": { "marked": "^0.7.0", @@ -86,7 +83,7 @@ "husky": "^3.1.0", "jsdom": "^15.1.1", "lerna": "^3.17.0", - "lint-staged": "^9.5.0", + "lint-staged": "^10.1.2", "live-server": "^1.2.1", "mkdirp": "^0.5.1", "mocha": "^5.2.0", From d32d91bebc54939585c4a371c8d5bf898f674d12 Mon Sep 17 00:00:00 2001 From: CHUXK Date: Fri, 10 Apr 2020 11:28:32 +0800 Subject: [PATCH 03/49] Update sidebar.js fix bug https://github.com/docsifyjs/docsify/issues/1110 --- src/core/event/sidebar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/event/sidebar.js b/src/core/event/sidebar.js index f252f2b48..5c09fb2b2 100644 --- a/src/core/event/sidebar.js +++ b/src/core/event/sidebar.js @@ -38,7 +38,8 @@ export function collapse(el) { dom.on(el, 'click', ({ target }) => { if ( target.nodeName === 'A' && - target.nextSibling && + target.nextSibling && + target.nextSibling.classList && target.nextSibling.classList.contains('app-sub-sidebar') ) { dom.toggleClass(target.parentNode, 'collapse'); From b4e7b219284ae88a1550e72ed0a198db1552f7f8 Mon Sep 17 00:00:00 2001 From: CHUXK Date: Fri, 10 Apr 2020 11:30:12 +0800 Subject: [PATCH 04/49] Update component.js fix bug https://github.com/docsifyjs/docsify/issues/1098 --- src/plugins/search/component.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/search/component.js b/src/plugins/search/component.js index 21add7ef2..1ac16fa24 100644 --- a/src/plugins/search/component.js +++ b/src/plugins/search/component.js @@ -171,11 +171,11 @@ function bindEvents() { let timeId; // Prevent to Fold sidebar - Docsify.dom.on( - $search, - 'click', - e => e.target.tagName !== 'A' && e.stopPropagation() - ); +// Docsify.dom.on( +// $search, +// 'click', +// e => e.target.tagName !== 'A' && e.stopPropagation() +// ); Docsify.dom.on($input, 'input', e => { clearTimeout(timeId); timeId = setTimeout(_ => doSearch(e.target.value.trim()), 100); From fed6a8393025c88699454d9eebaf2b66b278aea9 Mon Sep 17 00:00:00 2001 From: CHUXK Date: Wed, 15 Apr 2020 16:01:09 +0800 Subject: [PATCH 05/49] Linting Checks --- .../ core/\344\272\213\344\273\266/sidebar.js" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/core/event/sidebar.js => "src/ core/\344\272\213\344\273\266/sidebar.js" (98%) diff --git a/src/core/event/sidebar.js "b/src/ core/\344\272\213\344\273\266/sidebar.js" similarity index 98% rename from src/core/event/sidebar.js rename to "src/ core/\344\272\213\344\273\266/sidebar.js" index 5c09fb2b2..b15cb2afe 100644 --- a/src/core/event/sidebar.js +++ "b/src/ core/\344\272\213\344\273\266/sidebar.js" @@ -38,7 +38,7 @@ export function collapse(el) { dom.on(el, 'click', ({ target }) => { if ( target.nodeName === 'A' && - target.nextSibling && + target.nextSibling && target.nextSibling.classList && target.nextSibling.classList.contains('app-sub-sidebar') ) { From 1c43abe8ff8456d7fb65f36898e210126891e993 Mon Sep 17 00:00:00 2001 From: CHUXK Date: Wed, 15 Apr 2020 16:03:40 +0800 Subject: [PATCH 06/49] Linting Checks --- src/plugins/search/component.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/plugins/search/component.js b/src/plugins/search/component.js index 1ac16fa24..a2e4ec174 100644 --- a/src/plugins/search/component.js +++ b/src/plugins/search/component.js @@ -171,11 +171,6 @@ function bindEvents() { let timeId; // Prevent to Fold sidebar -// Docsify.dom.on( -// $search, -// 'click', -// e => e.target.tagName !== 'A' && e.stopPropagation() -// ); Docsify.dom.on($input, 'input', e => { clearTimeout(timeId); timeId = setTimeout(_ => doSearch(e.target.value.trim()), 100); From b9c38924d8c0429a04032db68ee1d966a664d161 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Thu, 23 Apr 2020 17:46:58 +0800 Subject: [PATCH 07/49] Update cover.md (#1134) --- docs/cover.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/cover.md b/docs/cover.md index 878747a7e..f2a0ce2d4 100644 --- a/docs/cover.md +++ b/docs/cover.md @@ -34,8 +34,6 @@ Set `coverpage` to **true**, and create a `_coverpage.md`: [Get Started](#docsify) ``` -!> A document site can have only one coverpage! - ## Custom background The background color is generated randomly by default. You can customize the background color or a background image: From 2623b94dd38424fce4a8b131fe72c42c5fe6358b Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Mon, 27 Apr 2020 13:09:45 +0800 Subject: [PATCH 08/49] Update index.html (#1144) --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 59e6911bd..1729635a7 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@ '.*?/awesome': 'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md', '.*?/changelog': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG.md', '/.*/_navbar.md': '/_navbar.md', - '/zh-cn/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-zh/master/$1', + '/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh/$1', '/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1', '/ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1', '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1' From b108c86d3884e6b396b36f2777d12dcd64e8f7ac Mon Sep 17 00:00:00 2001 From: vagra Date: Mon, 27 Apr 2020 16:55:55 +0800 Subject: [PATCH 09/49] reset and modify. --- src/core/event/scroll.js | 8 ++++---- src/core/router/util.js | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/event/scroll.js b/src/core/event/scroll.js index ef78443ba..47d64b417 100644 --- a/src/core/event/scroll.js +++ b/src/core/event/scroll.js @@ -1,5 +1,6 @@ import { isMobile } from '../util/env'; import * as dom from '../util/dom'; +import { removeParams } from '../router/util'; import config from '../config'; import Tweezer from 'tweezer.js'; @@ -59,8 +60,7 @@ function highlight(path) { return; } - const li = - nav[getNavKey(decodeURIComponent(path), last.getAttribute('data-id'))]; + const li = nav[getNavKey(path, last.getAttribute('data-id'))]; if (!li || li === active) { return; @@ -86,7 +86,7 @@ function highlight(path) { } function getNavKey(path, id) { - return `${path}?id=${id}`; + return `${decodeURIComponent(path)}?id=${decodeURIComponent(id)}`; } export function scrollActiveSidebar(router) { @@ -127,7 +127,7 @@ export function scrollActiveSidebar(router) { return; } - const path = router.getCurrentPath(); + const path = removeParams(router.getCurrentPath()); dom.off('scroll', () => highlight(path)); dom.on('scroll', () => highlight(path)); dom.on(sidebar, 'mouseover', () => { diff --git a/src/core/router/util.js b/src/core/router/util.js index ba2eed8a1..fc3e2f79d 100644 --- a/src/core/router/util.js +++ b/src/core/router/util.js @@ -44,6 +44,10 @@ export const isAbsolutePath = cached(path => { return /(:|(\/{2}))/g.test(path); }); +export const removeParams = cached(path => { + return path.split(/[?#]/)[0]; +}); + export const getParentPath = cached(path => { if (/\/$/g.test(path)) { return path; From 717991c90cf709f4da91fe32610129de6529266b Mon Sep 17 00:00:00 2001 From: Herbert <30955264+HerbertHe@users.noreply.github.com> Date: Tue, 28 Apr 2020 01:07:27 +0800 Subject: [PATCH 10/49] fix: rendering cover width bug --- src/themes/basic/_coverpage.styl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/themes/basic/_coverpage.styl b/src/themes/basic/_coverpage.styl index 001493225..3ad8149ea 100644 --- a/src/themes/basic/_coverpage.styl +++ b/src/themes/basic/_coverpage.styl @@ -4,6 +4,7 @@ section.cover background-repeat no-repeat background-size cover height 100vh + width 100vw display none &.show From b05949a1615a0358e58cf1fd9007cc42c1af319f Mon Sep 17 00:00:00 2001 From: Sytone Date: Mon, 27 Apr 2020 12:24:24 -0700 Subject: [PATCH 11/49] Add front matter to dev page Update embeded files documentation Add example with front matter Add various comments I used to understand code Updated front matter to have installed flag Added function to parse front matter Added intercept to remove front matter for embed --- docs/_media/example-with-yaml.md | 6 ++++++ docs/embed-files.md | 14 +++++++++++++- index.html | 1 + src/core/render/compiler.js | 15 +++++++++++++++ src/core/render/embed.js | 7 +++++++ src/core/render/utils.js | 20 ++++++++++++++++++++ src/plugins/front-matter/index.js | 8 ++++++++ 7 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 docs/_media/example-with-yaml.md diff --git a/docs/_media/example-with-yaml.md b/docs/_media/example-with-yaml.md new file mode 100644 index 000000000..081bedde2 --- /dev/null +++ b/docs/_media/example-with-yaml.md @@ -0,0 +1,6 @@ +--- +author: John Smith +date: 2020-1-1 +--- + +> This is from the `example.md` diff --git a/docs/embed-files.md b/docs/embed-files.md index dab2efe4e..d50387477 100644 --- a/docs/embed-files.md +++ b/docs/embed-files.md @@ -39,7 +39,20 @@ You will get it [filename](_media/example.md ':include :type=code') +## Markdown with YAML Front Matter + +When using Markdown, YAML front matter will be stripped from the rendered content. The attributes cannot be used in this case. + +```markdown +[filename](_media/example-with-yaml.md ':include') +``` + +You will get just the content + +[filename](_media/example-with-yaml.md ':include') + ## Embedded code fragments + Sometimes you don't want to embed a whole file. Maybe because you need just a few lines but you want to compile and test the file in CI. ```markdown @@ -53,7 +66,6 @@ Example: [filename](_media/example.js ':include :type=code :fragment=demo') - ## Tag attribute If you embed the file as `iframe`, `audio` and `video`, then you may need to set the attributes of these tags. diff --git a/index.html b/index.html index 59e6911bd..fba1a4074 100644 --- a/index.html +++ b/index.html @@ -76,6 +76,7 @@ + diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index c4c026205..5cb8f9e5a 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -121,6 +121,21 @@ export class Compiler { }; } + /** + * Pulls content from file and renders inline on the page as a embedded item. + * + * This allows you to embed different file types on the returned + * page. + * The basic format is: + * ``` + * [filename](_media/example.md ':include') + * ``` + * + * @param {string} href The href to the file to embed in the page. + * @param {string} title Title of the link used to make the embed. + * + * @return {type} Return value description. + */ compileEmbed(href, title) { const { str, config } = getAndRemoveConfig(title); let embed; diff --git a/src/core/render/embed.js b/src/core/render/embed.js index 083fb7f97..8b84c7acb 100644 --- a/src/core/render/embed.js +++ b/src/core/render/embed.js @@ -36,6 +36,13 @@ function walkFetchEmbed({ embedTokens, compile, fetch }, cb) { return x; }); + // This may contain YAML front matter and will need to be stripped. + const frontMatterInstalled = + ($docsify.frontMatter || {}).installed || false; + if (frontMatterInstalled === true) { + text = $docsify.frontMatter.parseMarkdown(text); + } + embedToken = compile.lexer(text); } else if (token.embed.type === 'code') { if (token.embed.fragment) { diff --git a/src/core/render/utils.js b/src/core/render/utils.js index 6f2d14fa3..100d595cd 100644 --- a/src/core/render/utils.js +++ b/src/core/render/utils.js @@ -1,3 +1,23 @@ +/** + * Converts a colon formatted string to a object with properties. + * + * This is process a provided string and look for any tokens in the format + * of `:name[=value]` and then convert it to a object and return. + * An example of this is ':include :type=code :fragment=demo' is taken and + * then converted to: + * + * ``` + * { + * include: '', + * type: 'code', + * fragment: 'demo' + * } + * ``` + * + * @param {string} str The string to parse. + * + * @return {object} The original string and parsed object, { str, config }. + */ export function getAndRemoveConfig(str = '') { const config = {}; diff --git a/src/plugins/front-matter/index.js b/src/plugins/front-matter/index.js index e91c4efc3..a0aac5b63 100644 --- a/src/plugins/front-matter/index.js +++ b/src/plugins/front-matter/index.js @@ -1,6 +1,14 @@ import parser from './parser'; const install = function(hook, vm) { + // Used to remove front matter from embedded pages if installed. + vm.config.frontMatter = {}; + vm.config.frontMatter.installed = true; + vm.config.frontMatter.parseMarkdown = function(content) { + const { body } = parser(content); + return body; + }; + hook.beforeEach(content => { const { attributes, body } = parser(content); From 468ee2d58afc9850730843c54fd9c5b7cff3e0c2 Mon Sep 17 00:00:00 2001 From: Laura Kishimoto Date: Mon, 27 Apr 2020 21:47:49 +0100 Subject: [PATCH 12/49] Improve accessibility of viewport meta --- cypress/fixtures/tpl/docs.index.html | 2 +- docs/index.html | 4 ++-- docs/ssr.md | 2 +- packages/docsify-server-renderer/README.md | 2 +- server.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cypress/fixtures/tpl/docs.index.html b/cypress/fixtures/tpl/docs.index.html index 94d9526e1..6a8b41a4c 100644 --- a/cypress/fixtures/tpl/docs.index.html +++ b/cypress/fixtures/tpl/docs.index.html @@ -16,7 +16,7 @@ diff --git a/docs/index.html b/docs/index.html index 39c32b814..b99db702d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -9,12 +9,12 @@ - + - +