forked from byoungd/English-level-up-tips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
253 lines (249 loc) · 8.69 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>English-level-up-tips</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="English, tips, learning" />
<meta
name="keywords"
content="An advanced guide to learn English which might benefit you a lot."
/>
<meta name="author" content="byoungd" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0"
/>
<!-- docsify-themeable -->
<link
rel="stylesheet"
media="(prefers-color-scheme: dark)"
href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple-dark.css"
/>
<link
rel="stylesheet"
media="(prefers-color-scheme: light)"
href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css"
/>
<!-- End -->
<!-- begin for docsify katex -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
/>
<script
defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
></script>
<!-- the version of marked must between 2.1.0 -->
<script src="https://cdn.jsdelivr.net/npm/marked@4"></script>
<!-- End -->
<!-- slidebar collapse -->
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/npm/docsify-sidebar-collapse/dist/sidebar.min.css"
/>
<!-- mermaid -->
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.css"
/>
<script src="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<!-- End -->
<!-- begin for markmap -->
<script src="https://cdn.jsdelivr.net/npm/d3@6"></script>
<script src="https://cdn.jsdelivr.net/npm/markmap-view"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser/index.min.js"></script>
<!-- End -->
<style type="text/css">
iframe {
display: block;
border: none;
height: 75vh;
width: 100%;
}
</style>
</head>
<body>
<div id="app"></div>
<script>
let num = 0;
mermaid.initialize({ startOnLoad: false });
markmapSvg = [];
const transformer = new markmap.Transformer();
window.$docsify = {
name: "content", // 目录的标题
repo: "https://github.com/byoungd/English-level-up-tips", // 右上角的挂件
loadSidebar: "SUMMARY.md",
alias: {
"/.*/SUMMARY.md": "/SUMMARY.md",
},
subMaxLevel: 3, // 子目录最大层级, 有助于显示 markdown 的层级
auto2top: true, // 自动跳转至顶部
markdown: {
renderer: {
code: function (code, lang) {
if (lang === "mermaid") {
return (
'<div class="mermaid" style="background:#E1EFD9" >' +
mermaid.render("mermaid-svg-" + num++, code) +
"</div>"
);
} else if (lang == "markmap") {
const { root: data } = transformer.transform(code);
let currentNum = num;
markmapSvg.push(function () {
let elem = document.getElementById(
"markmap-svg-" + currentNum
);
const mm = new markmap.Markmap(elem, null);
if (data) {
mm.setData(data);
const { minX, maxX, minY, maxY } = mm.state;
const naturalWidth = maxY - minY;
const naturalHeight = maxX - minX;
elem.style.width = naturalWidth + "px";
elem.style.height = naturalHeight + "px";
mm.fit(); // always fit for the first render
}
});
return `<svg class="markmap" id="markmap-svg-${num++}"></svg>`;
}
return this.origin.code.apply(this, arguments);
},
},
},
plugins: [
function (hook, vm) {
hook.beforeEach(function (html) {
num = 0;
markmapSvg = [];
let url =
"https://github.com/byoungd/English-level-up-tips/blob/master/" +
vm.route.file;
let editHtml = "[:memo: EDIT DOCUMENT](" + url + ")\n";
return (
editHtml +
html.replace(
/<a\s+(?:[^>]*?\s+)?href\s*=\s*(["'])#(.*?)\1.*?>/g,
(m, g1, g2) => m.replace(g2, vm.route.path + "#" + g2)
)
);
});
hook.doneEach(function () {
markmapSvg.forEach((fn) => fn());
});
},
],
};
</script>
<!-- docsify-katex for latex -->
<script>
// import katex from "katex";
// import marked from "marked";
(function () {
let originMarkdown = window.$docsify.markdown;
let newMarked = marked; // version above 2.1.0
window.$docsify.markdown = newMarkdown;
return;
function newMarkdown(originMarked, originRenderer) {
// in docsify.js: `window.marked = marked;`
// this will overwrite the marked
// here `let newMarked = marked;` will not right
const mathExtension = {
name: "math",
level: "inline",
start(src) {
let index = src.match(/\$/)?.index;
return index;
},
tokenizer(src, tokens) {
const blockRule = /^\$\$((\\.|[^\$\\])+)\$\$/;
const inlineRule = /^\$((\\.|[^\$\\])+)\$/;
let match;
if ((match = blockRule.exec(src))) {
return {
type: "math",
raw: match[0],
text: match[1].trim(),
mathLevel: "block",
};
} else if ((match = inlineRule.exec(src))) {
return {
type: "math",
raw: match[0],
text: match[1].trim(),
mathLevel: "inline",
};
}
},
renderer(token) {
if (token.mathLevel === "block") {
return katex.renderToString(token.text, {
throwOnError: false,
displayMode: true,
});
} else if (token.mathLevel === "inline") {
return katex.renderToString(token.text, {
throwOnError: false,
displayMode: false,
});
}
},
};
const merge =
Object.assign ||
function (to) {
for (let i = 1; i < arguments.length; i++) {
const from = Object(arguments[i]);
for (const key in from) {
if (hasOwn.call(from, key)) {
to[key] = from[key];
}
}
}
return to;
};
let opts = originMarkdown || {};
if (isFn(opts)) {
opts = opts.apply(
this, // make it right: return this.origin.code(src);
originMarked,
originRenderer
).defaults;
} else {
opts = merge(opts, {
renderer: merge(originRenderer, opts.renderer),
});
}
newMarked.setOptions(opts);
newMarked.use({ extensions: [mathExtension] });
return newMarked.parse;
function isFn(obj) {
return typeof obj === "function";
}
}
})();
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<!-- copy to clipboard -->
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
<!-- slidebar collapse -->
<script src="//cdn.jsdelivr.net/npm/docsify-sidebar-collapse/dist/docsify-sidebar-collapse.min.js"></script>
<!-- search -->
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.js"></script>
<!-- zoom image -->
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/zoom-image.min.js"></script>
<!-- docsify-themeable -->
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vanilla-back-to-top.min.js"></script>
<script>
addBackToTop({
diameter: 56,
backgroundColor: "rgb(255, 82, 82)",
textColor: "#fff",
});
</script>
</body>
</html>