Compare commits
No commits in common. "3185864cef432dbac7bbe360aba8f77a25078aea" and "e478eb5a8319cdd78ab0334563e2f29767071972" have entirely different histories.
3185864cef
...
e478eb5a83
|
|
@ -16,16 +16,10 @@
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"
|
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"
|
||||||
/>
|
/>
|
||||||
<!-- 添加MathJax配置 -->
|
<script
|
||||||
<script type="text/x-mathjax-config">
|
defer
|
||||||
MathJax.Hub.Config({
|
src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/highlight.js/11.4.0/highlight.min.js"
|
||||||
tex2jax: {
|
></script>
|
||||||
inlineMath: [['$','$']],
|
|
||||||
displayMath: [['$$','$$']],
|
|
||||||
processEscapes: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<title>anki-md模板测试</title>
|
<title>anki-md模板测试</title>
|
||||||
</head>
|
</head>
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -54,18 +48,18 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
<div class="md-content">
|
<div class="md-content">
|
||||||
这是一个行内公式
|
|
||||||
$$E=mc^2$$
|
|
||||||
和一个块级公式
|
|
||||||
$$\\frac{d}{dx}(x^n) = nx^{n-1}$$
|
|
||||||
***
|
|
||||||
> 呵呵呵
|
> 呵呵呵
|
||||||
|
> 呵呵呵哈哈哈哈
|
||||||
|
|
||||||
> 喜喜
|
> 喜喜
|
||||||
|
|
||||||
# 一级标题
|
# 一级标题
|
||||||
## 二级标题
|
## 二级标题
|
||||||
### 三级标题
|
### 三级标题
|
||||||
|
#### 四级标题
|
||||||
|
##### 五级标题
|
||||||
|
###### 六级标题
|
||||||
---
|
---
|
||||||
**加粗**
|
**加粗**
|
||||||
*斜体*
|
*斜体*
|
||||||
|
|
@ -92,44 +86,22 @@ $$\\frac{d}{dx}(x^n) = nx^{n-1}$$
|
||||||
console.log('hello world')
|
console.log('hello world')
|
||||||
```
|
```
|
||||||
</div>
|
</div>
|
||||||
|
<!--
|
||||||
<script>
|
整个script内容(包括script标签)
|
||||||
var getResources = [
|
需要复制到anki的卡片模板中
|
||||||
getScript(
|
-->
|
||||||
"https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/markdown-it/12.3.2/markdown-it.min.js"
|
<!-- https://github.com/markdown-it/markdown-it -->
|
||||||
),
|
<script
|
||||||
getScript(
|
defer
|
||||||
"https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/highlight.js/11.4.0/highlight.min.js"
|
src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/markdown-it/12.3.2/markdown-it.min.js"
|
||||||
),
|
></script>
|
||||||
// 添加markdown-it-texmath插件
|
<!-- 代码高亮库 -->
|
||||||
getScript(
|
<script
|
||||||
"https://cdn.jsdelivr.net/npm/markdown-it-texmath/texmath.min.js"
|
defer
|
||||||
),
|
src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/highlight.js/11.4.0/highlight.min.js"
|
||||||
// 添加MathJax
|
></script>
|
||||||
getScript(
|
<script defer>
|
||||||
"https://cdn.bootcdn.net/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.min.js"
|
"use strict";
|
||||||
)
|
|
||||||
];
|
|
||||||
|
|
||||||
// 加载资源并初始化
|
|
||||||
Promise.all(getResources)
|
|
||||||
.then(() => {
|
|
||||||
parseMarkDownFn();
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
consoleLog("Failed to load required resources: " + error);
|
|
||||||
});
|
|
||||||
|
|
||||||
function getScript(url) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const script = document.createElement("script");
|
|
||||||
script.onload = resolve;
|
|
||||||
script.onerror = () =>
|
|
||||||
reject(new Error(`Failed to load script from ${url}`));
|
|
||||||
script.src = url;
|
|
||||||
document.head.appendChild(script);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 在anki中通过窗口查看调试信息 没控制台啊
|
// 在anki中通过窗口查看调试信息 没控制台啊
|
||||||
function consoleLog(str) {
|
function consoleLog(str) {
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
|
|
@ -172,16 +144,6 @@ console.log('hello world')
|
||||||
return ""; // use external default escaping
|
return ""; // use external default escaping
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 配置markdown-it-texmath插件
|
|
||||||
if (window.texmath) {
|
|
||||||
md.use(window.texmath, {
|
|
||||||
engine: MathJax,
|
|
||||||
delimiters: 'dollars',
|
|
||||||
katexOptions: { macros: {"\\RR": "\\mathbb{R}"} }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelectorAll(".md-content").forEach((div, index) => {
|
document.querySelectorAll(".md-content").forEach((div, index) => {
|
||||||
console.log("查找到的容器元素", div);
|
console.log("查找到的容器元素", div);
|
||||||
// 需要去除首尾空格 不然markdown-it会解析错误
|
// 需要去除首尾空格 不然markdown-it会解析错误
|
||||||
|
|
@ -204,6 +166,15 @@ console.log('hello world')
|
||||||
// 不能从body直接插入元素 anki 不刷新的
|
// 不能从body直接插入元素 anki 不刷新的
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
// TEMP 复制到卡片中要打开注释 去掉下边的代码。
|
||||||
|
// parseMarkDownFn();
|
||||||
|
|
||||||
|
// TEMP 在浏览器中测试的时候使用
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
// 你的主要代码
|
||||||
|
"use strict";
|
||||||
|
parseMarkDownFn();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue