Skip to content

Commit 9afa666

Browse files
committed
chore: removed circular dep and css.escape
1 parent 406670c commit 9afa666

File tree

15 files changed

+35
-42
lines changed

15 files changed

+35
-42
lines changed

package-lock.json

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
"conventional-changelog-cli": "^2.0.25",
7777
"copy-dir": "^1.2.0",
7878
"cross-env": "^6.0.3",
79-
"css.escape": "^1.5.1",
8079
"cssnano": "^4.1.10",
8180
"cypress": "^3.8.1",
8281
"cypress-image-snapshot": "^3.1.1",

packages/docsify-server-renderer/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { readFileSync } from 'fs';
22
import { resolve, basename } from 'path';
33
import resolvePathname from 'resolve-pathname';
4-
import debug from 'debug';
5-
import fetch from 'node-fetch';
64
import { AbstractHistory } from '../../src/core/router/history/abstract';
75
import { Compiler } from '../../src/core/render/compiler';
86
import { isAbsolutePath } from '../../src/core/router/util';
97
import * as tpl from '../../src/core/render/tpl';
108
import { prerenderEmbed } from '../../src/core/render/embed';
9+
import fetch from 'node-fetch';
10+
import debug from 'debug';
1111

1212
function cwd(...args) {
1313
return resolve(process.cwd(), ...args);

src/core/event/scroll.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Tweezer from 'tweezer.js';
21
import { isMobile } from '../util/env';
32
import * as dom from '../util/dom';
43
import config from '../config';
4+
import Tweezer from 'tweezer.js';
55

66
const nav = {};
77
let hoverOver = false;

src/core/global-api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import marked from 'marked';
2-
import prism from 'prismjs';
31
import * as util from './util';
42
import * as dom from './util/dom';
53
import { Compiler } from './render/compiler';
64
import { slugify } from './render/slugify';
75
import { get } from './fetch/ajax';
6+
import prism from 'prismjs';
7+
import marked from 'marked';
88

99
export default function() {
1010
window.Docsify = {

src/core/render/compiler.js

+2-22
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,20 @@
1-
import marked from 'marked';
21
import { isAbsolutePath, getPath, getParentPath } from '../router/util';
32
import { isFn, merge, cached, isPrimitive } from '../util/core';
43
import { tree as treeTpl } from './tpl';
54
import { genTree } from './gen-tree';
65
import { slugify } from './slugify';
76
import { emojify } from './emojify';
7+
import { getAndRemoveConfig } from './utils';
88
import { imageCompiler } from './compiler/image';
99
import { highlightCodeCompiler } from './compiler/code';
1010
import { paragraphCompiler } from './compiler/paragraph';
1111
import { taskListCompiler } from './compiler/taskList';
1212
import { taskListItemCompiler } from './compiler/taskListItem';
1313
import { linkCompiler } from './compiler/link';
14+
import marked from 'marked';
1415

1516
const cachedLinks = {};
1617

17-
export function getAndRemoveConfig(str = '') {
18-
const config = {};
19-
20-
if (str) {
21-
str = str
22-
.replace(/^'/, '')
23-
.replace(/'$/, '')
24-
.replace(/(?:^|\s):([\w-]+:?)=?([\w-]+)?/g, (m, key, value) => {
25-
if (key.indexOf(':') === -1) {
26-
config[key] = (value && value.replace(/"/g, '')) || true;
27-
return '';
28-
}
29-
30-
return m;
31-
})
32-
.trim();
33-
}
34-
35-
return { str, config };
36-
}
37-
3818
const compileMedia = {
3919
markdown(url) {
4020
return {

src/core/render/compiler/headline.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getAndRemoveConfig } from '../compiler';
1+
import { getAndRemoveConfig } from '../utils';
22
import { slugify } from './slugify';
33

44
export const headingCompiler = ({ renderer, router, _self }) =>

src/core/render/compiler/link.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getAndRemoveConfig } from '../compiler';
1+
import { getAndRemoveConfig } from '../utils';
22
import { isAbsolutePath } from '../../router/util';
33

44
export const linkCompiler = ({ renderer, router, linkTarget, compilerClass }) =>

src/core/render/embed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import stripIndent from 'strip-indent';
21
import { get } from '../fetch/ajax';
32
import { merge } from '../util/core';
3+
import stripIndent from 'strip-indent';
44

55
const cached = {};
66

src/core/render/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable no-unused-vars */
2-
import tinydate from 'tinydate';
32
import * as dom from '../util/dom';
43
import cssVars from '../util/polyfill/css-vars';
54
import { callHook } from '../init/lifecycle';
@@ -11,6 +10,7 @@ import { scrollActiveSidebar } from '../event/scroll';
1110
import { Compiler } from './compiler';
1211
import * as tpl from './tpl';
1312
import { prerenderEmbed } from './embed';
13+
import tinydate from 'tinydate';
1414

1515
function executeScript() {
1616
const script = dom

src/core/render/utils.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export function getAndRemoveConfig(str = '') {
2+
const config = {};
3+
4+
if (str) {
5+
str = str
6+
.replace(/^'/, '')
7+
.replace(/'$/, '')
8+
.replace(/(?:^|\s):([\w-]+:?)=?([\w-]+)?/g, (m, key, value) => {
9+
if (key.indexOf(':') === -1) {
10+
config[key] = (value && value.replace(/"/g, '')) || true;
11+
return '';
12+
}
13+
14+
return m;
15+
})
16+
.trim();
17+
}
18+
19+
return { str, config };
20+
}

src/core/router/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { supportsPushState } from '../util/env';
22
import * as dom from '../util/dom';
3+
import { noop } from '../util/core';
34
import { HashHistory } from './history/hash';
45
import { HTML5History } from './history/html5';
5-
import { noop } from '../util/core';
66

77
export function routerMixin(proto) {
88
proto.route = {};

test/unit/base.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require = require('esm')(
33
module /* , options */
44
); /* eslint-disable-line no-global-assign */
5-
const { expect } = require('chai');
65
const { History } = require('../../src/core/router/history/base');
6+
const { expect } = require('chai');
77

88
class MockHistory extends History {
99
parse(path) {

test/unit/render.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { expect } = require('chai');
21
const { init, expectSameDom } = require('../_helper');
2+
const { expect } = require('chai');
33

44
describe('render', function() {
55
it('important content (tips)', async function() {

test/unit/util.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require = require('esm')(
33
module /* , options */
44
); /* eslint-disable-line no-global-assign */
5-
const { expect } = require('chai');
65
const { resolvePath } = require('../../src/core/router/util');
6+
const { expect } = require('chai');
77

88
describe('router/util', function() {
99
it('resolvePath', async function() {

0 commit comments

Comments
 (0)