From 952f4c921b7a6a558c500ca6b105582d39ad36a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Thu, 30 Jul 2020 17:58:45 +0800 Subject: [PATCH 1/4] fix: the uncaught typeerror when el is null (#1308) --- src/core/router/history/hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/router/history/hash.js b/src/core/router/history/hash.js index 166af9ab5..caaea4571 100644 --- a/src/core/router/history/hash.js +++ b/src/core/router/history/hash.js @@ -39,7 +39,7 @@ export class HashHistory extends History { on('click', e => { const el = e.target.tagName === 'A' ? e.target : e.target.parentNode; - if (el.tagName === 'A' && !/_blank/.test(el.target)) { + if (el && el.tagName === 'A' && !/_blank/.test(el.target)) { navigating = true; } }); From 90d283d340502456a5d8495df596bb4a02ceb39b Mon Sep 17 00:00:00 2001 From: Mattia Astorino Date: Thu, 30 Jul 2020 12:11:04 +0200 Subject: [PATCH 2/4] fix: convert {docsify-ignore} and {docsify-ignore-all} to HTML comments (#1318) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * breaking: convert {docsify-ignore} and {docsify-ignore-all} to HTML comments Close https://github.com/docsifyjs/docsify/issues/441 * chore: add ignore and ignore-all unit tests Co-authored-by: 沈唁 <52o@qq52o.cn> --- docs/more-pages.md | 10 ++++---- src/core/render/compiler.js | 8 +++--- src/core/render/compiler/headline.js | 8 +++--- test/unit/render.test.js | 37 ++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/docs/more-pages.md b/docs/more-pages.md index 429eaf97a..0f9386848 100644 --- a/docs/more-pages.md +++ b/docs/more-pages.md @@ -114,24 +114,24 @@ A custom sidebar can also automatically generate a table of contents by setting ## Ignoring Subheaders -When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `{docsify-ignore}` to it. +When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `` to it. ```markdown # Getting Started -## Header {docsify-ignore} +## Header This header won't appear in the sidebar table of contents. ``` -To ignore all headers on a specific page, you can use `{docsify-ignore-all}` on the first header of the page. +To ignore all headers on a specific page, you can use `` on the first header of the page. ```markdown -# Getting Started {docsify-ignore-all} +# Getting Started ## Header This header won't appear in the sidebar table of contents. ``` -Both `{docsify-ignore}` and `{docsify-ignore-all}` will not be rendered on the page when used. +Both `` and `` will not be rendered on the page when used. diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 4eaf51215..669b6226f 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -208,14 +208,14 @@ export class Compiler { let { str, config } = getAndRemoveConfig(text); const nextToc = { level, title: str }; - if (/{docsify-ignore}/g.test(str)) { - str = str.replace('{docsify-ignore}', ''); + if (//g.test(str)) { + str = str.replace('', ''); nextToc.title = str; nextToc.ignoreSubHeading = true; } - if (/{docsify-ignore-all}/g.test(str)) { - str = str.replace('{docsify-ignore-all}', ''); + if (//g.test(str)) { + str = str.replace('', ''); nextToc.title = str; nextToc.ignoreAllSubs = true; } diff --git a/src/core/render/compiler/headline.js b/src/core/render/compiler/headline.js index 3f5c22039..cfbad7b25 100644 --- a/src/core/render/compiler/headline.js +++ b/src/core/render/compiler/headline.js @@ -6,14 +6,14 @@ export const headingCompiler = ({ renderer, router, _self }) => let { str, config } = getAndRemoveConfig(text); const nextToc = { level, title: str }; - if (/{docsify-ignore}/g.test(str)) { - str = str.replace('{docsify-ignore}', ''); + if (//g.test(str)) { + str = str.replace('', ''); nextToc.title = str; nextToc.ignoreSubHeading = true; } - if (/{docsify-ignore-all}/g.test(str)) { - str = str.replace('{docsify-ignore-all}', ''); + if (//g.test(str)) { + str = str.replace('', ''); nextToc.title = str; nextToc.ignoreAllSubs = true; } diff --git a/test/unit/render.test.js b/test/unit/render.test.js index 28e88ac0e..43a87248d 100644 --- a/test/unit/render.test.js +++ b/test/unit/render.test.js @@ -251,6 +251,43 @@ describe('render', function() { ` ); }); + + it('ignore', async function() { + const { docsify } = await init(); + const output = docsify.compiler.compile( + '## h2 tag ' + ); + expectSameDom( + output, + ` +

+ + h2 tag + +

` + ); + }); + + it('ignore-all', async function() { + const { docsify } = await init(); + const output = docsify.compiler.compile( + `# h1 tag ` + `\n## h2 tag` + ); + expectSameDom( + output, + ` +

+ + h1 tag + +

+

+ + h2 tag + +

` + ); + }); }); describe('link', function() { From 9150678d262904add0ea27a06f427ab529001863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Thu, 30 Jul 2020 19:09:23 +0800 Subject: [PATCH 3/4] fix typo (#1309) * fix typo * Update README.md --- packages/docsify-server-renderer/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/docsify-server-renderer/README.md b/packages/docsify-server-renderer/README.md index 76c5f80dc..9968b1e0b 100644 --- a/packages/docsify-server-renderer/README.md +++ b/packages/docsify-server-renderer/README.md @@ -14,7 +14,7 @@ var readFileSync = require('fs').readFileSync // init var renderer = new Renderer({ - template: readFileSync('./docs/index.template.html', 'utf-8')., + template: readFileSync('./docs/index.template.html', 'utf-8'), config: { name: 'docsify', repo: 'docsifyjs/docsify' @@ -35,12 +35,12 @@ renderer.renderToString(url) docsify - + - + ``` From 2048610aacd4e3c6a592f4247834a726c7ca33fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Sat, 1 Aug 2020 17:04:08 +0800 Subject: [PATCH 4/4] fix: {docsify-updated} in the sample code is parsed into time (#1321) --- docs/index.html | 3 ++- index.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/index.html b/docs/index.html index 766d1acd8..d90431ee2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -33,7 +33,8 @@ '/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1', '/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1', '/ru-ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1', - '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1' + '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1', + '/write-a-plugin': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/docs/write-a-plugin.md' }, auto2top: true, coverpage: true, diff --git a/index.html b/index.html index ddacdecda..9f443671b 100644 --- a/index.html +++ b/index.html @@ -28,7 +28,8 @@ '/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1', '/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1', '/ru-ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1', - '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1' + '/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1', + '/write-a-plugin': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/docs/write-a-plugin.md' }, auto2top: true, basePath: '/docs/',