mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
Merge branch 'develop' into feat/vue-options
This commit is contained in:
commit
a9be6f20d2
14
packages/docsify-server-renderer/package-lock.json
generated
14
packages/docsify-server-renderer/package-lock.json
generated
@ -16,11 +16,11 @@
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.0.tgz",
|
||||
"integrity": "sha512-jjO6JD2rKfiZQnBoRzhRTbXjHLGLfH+UtGkWLc/UXAh/rzZMyjbgn0NcfFpqT8nd1kTtFnDiJcrIFkq4UKeJVg==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
},
|
||||
"delegate": {
|
||||
@ -45,9 +45,9 @@
|
||||
}
|
||||
},
|
||||
"dompurify": {
|
||||
"version": "2.0.17",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.0.17.tgz",
|
||||
"integrity": "sha512-nNwwJfW55r8akD8MSFz6k75bzyT2y6JEa1O3JrZFBf+Y5R9JXXU4OsRl0B9hKoPgHTw2b7ER5yJ5Md97MMUJPg=="
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.1.1.tgz",
|
||||
"integrity": "sha512-NijiNVkS/OL8mdQL1hUbCD6uty/cgFpmNiuFxrmJ5YPH2cXrPKIewoixoji56rbZ6XBPmtM8GA8/sf9unlSuwg=="
|
||||
},
|
||||
"good-listener": {
|
||||
"version": "1.2.2",
|
||||
|
||||
@ -15,9 +15,9 @@
|
||||
"test": "echo 'hello'"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
"debug": "^4.3.0",
|
||||
"docsify": "^4.11.6",
|
||||
"dompurify": "^2.0.17",
|
||||
"dompurify": "^2.1.1",
|
||||
"node-fetch": "^2.6.0",
|
||||
"resolve-pathname": "^3.0.0"
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import { tree as treeTpl } from './tpl';
|
||||
import { genTree } from './gen-tree';
|
||||
import { slugify } from './slugify';
|
||||
import { emojify } from './emojify';
|
||||
import { getAndRemoveConfig } from './utils';
|
||||
import { getAndRemoveConfig, removeAtag } from './utils';
|
||||
import { imageCompiler } from './compiler/image';
|
||||
import { highlightCodeCompiler } from './compiler/code';
|
||||
import { paragraphCompiler } from './compiler/paragraph';
|
||||
@ -206,29 +206,29 @@ export class Compiler {
|
||||
*/
|
||||
origin.heading = renderer.heading = function(text, level) {
|
||||
let { str, config } = getAndRemoveConfig(text);
|
||||
const nextToc = { level, title: str };
|
||||
const nextToc = { level, title: removeAtag(str) };
|
||||
|
||||
if (/<!-- {docsify-ignore} -->/g.test(str)) {
|
||||
str = str.replace('<!-- {docsify-ignore} -->', '');
|
||||
nextToc.title = str;
|
||||
nextToc.title = removeAtag(str);
|
||||
nextToc.ignoreSubHeading = true;
|
||||
}
|
||||
|
||||
if (/{docsify-ignore}/g.test(str)) {
|
||||
str = str.replace('{docsify-ignore}', '');
|
||||
nextToc.title = str;
|
||||
nextToc.title = removeAtag(str);
|
||||
nextToc.ignoreSubHeading = true;
|
||||
}
|
||||
|
||||
if (/<!-- {docsify-ignore-all} -->/g.test(str)) {
|
||||
str = str.replace('<!-- {docsify-ignore-all} -->', '');
|
||||
nextToc.title = str;
|
||||
nextToc.title = removeAtag(str);
|
||||
nextToc.ignoreAllSubs = true;
|
||||
}
|
||||
|
||||
if (/{docsify-ignore-all}/g.test(str)) {
|
||||
str = str.replace('{docsify-ignore-all}', '');
|
||||
nextToc.title = str;
|
||||
nextToc.title = removeAtag(str);
|
||||
nextToc.ignoreAllSubs = true;
|
||||
}
|
||||
|
||||
|
||||
@ -1,32 +1,32 @@
|
||||
import { getAndRemoveConfig } from '../utils';
|
||||
import { getAndRemoveConfig, removeAtag } from '../utils';
|
||||
import { slugify } from './slugify';
|
||||
|
||||
export const headingCompiler = ({ renderer, router, _self }) =>
|
||||
(renderer.code = (text, level) => {
|
||||
let { str, config } = getAndRemoveConfig(text);
|
||||
const nextToc = { level, title: str };
|
||||
const nextToc = { level, title: removeAtag(str) };
|
||||
|
||||
if (/<!-- {docsify-ignore} -->/g.test(str)) {
|
||||
str = str.replace('<!-- {docsify-ignore} -->', '');
|
||||
nextToc.title = str;
|
||||
nextToc.title = removeAtag(str);
|
||||
nextToc.ignoreSubHeading = true;
|
||||
}
|
||||
|
||||
if (/{docsify-ignore}/g.test(str)) {
|
||||
str = str.replace('{docsify-ignore}', '');
|
||||
nextToc.title = str;
|
||||
nextToc.title = removeAtag(str);
|
||||
nextToc.ignoreSubHeading = true;
|
||||
}
|
||||
|
||||
if (/<!-- {docsify-ignore-all} -->/g.test(str)) {
|
||||
str = str.replace('<!-- {docsify-ignore-all} -->', '');
|
||||
nextToc.title = str;
|
||||
nextToc.title = removeAtag(str);
|
||||
nextToc.ignoreAllSubs = true;
|
||||
}
|
||||
|
||||
if (/{docsify-ignore-all}/g.test(str)) {
|
||||
str = str.replace('{docsify-ignore-all}', '');
|
||||
nextToc.title = str;
|
||||
nextToc.title = removeAtag(str);
|
||||
nextToc.ignoreAllSubs = true;
|
||||
}
|
||||
|
||||
|
||||
@ -38,3 +38,13 @@ export function getAndRemoveConfig(str = '') {
|
||||
|
||||
return { str, config };
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the <a> tag from sidebar when the header with link, details see issue 1069
|
||||
* @param {string} str The string to deal with.
|
||||
*
|
||||
* @return {string} str The string after delete the <a> element.
|
||||
*/
|
||||
export function removeAtag(str = '') {
|
||||
return str.replace(/(<\/?a.*?>)/gi, '');
|
||||
}
|
||||
|
||||
@ -226,6 +226,9 @@ export function init(config, vm) {
|
||||
namespaceSuffix = matches[0];
|
||||
}
|
||||
}
|
||||
paths.unshift(namespaceSuffix + '/');
|
||||
} else {
|
||||
paths.unshift('/');
|
||||
}
|
||||
|
||||
const expireKey = resolveExpireKey(config.namespace) + namespaceSuffix;
|
||||
|
||||
38
test/e2e/search.test.js
Normal file
38
test/e2e/search.test.js
Normal file
@ -0,0 +1,38 @@
|
||||
const docsifyInit = require('../helpers/docsify-init');
|
||||
|
||||
// Suite
|
||||
// -----------------------------------------------------------------------------
|
||||
describe('Search Plugin Tests', function() {
|
||||
// Tests
|
||||
// ---------------------------------------------------------------------------
|
||||
test('search readme', async () => {
|
||||
const docsifyInitConfig = {
|
||||
markdown: {
|
||||
homepage: `
|
||||
# Hello World
|
||||
|
||||
This is the homepage.
|
||||
`,
|
||||
sidebar: `
|
||||
- [Home page](/)
|
||||
- [Test Page](test)
|
||||
`,
|
||||
},
|
||||
routes: {
|
||||
'/test.md': `
|
||||
# Test Page
|
||||
|
||||
This is a custom route.
|
||||
`,
|
||||
},
|
||||
scriptURLs: ['/lib/plugins/search.min.js'],
|
||||
};
|
||||
|
||||
await docsifyInit(docsifyInitConfig);
|
||||
await page.fill('input[type=search]', 'hello');
|
||||
await expect(page).toEqualText('.results-panel h2', 'Hello World');
|
||||
await page.click('.clear-button');
|
||||
await page.fill('input[type=search]', 'test');
|
||||
await expect(page).toEqualText('.results-panel h2', 'Test Page');
|
||||
});
|
||||
});
|
||||
15
test/unit/render-util.test.js
Normal file
15
test/unit/render-util.test.js
Normal file
@ -0,0 +1,15 @@
|
||||
const { removeAtag } = require(`${SRC_PATH}/core/render/utils`);
|
||||
|
||||
// Suite
|
||||
// -----------------------------------------------------------------------------
|
||||
describe('core/render/utils', () => {
|
||||
// removeAtag()
|
||||
// ---------------------------------------------------------------------------
|
||||
describe('removeAtag()', () => {
|
||||
test('removeAtag from a link', () => {
|
||||
const result = removeAtag('<a href="www.example.com">content</a>');
|
||||
|
||||
expect(result).toEqual('content');
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user