CHENXCHEN / hexo-renderer-markdown-it-plus

Markdown-it is a markdown parser, done right. A faster and CommonMark compliant alternative for Hexo.
https://chchc.me/hexo-article/2017/07/27/hexo-renderer-markdown-it-plus-plugin-demo/
MIT License
117 stars 22 forks source link

脚注中的数学公式不能正确渲染 #6

Closed wafer-li closed 6 years ago

wafer-li commented 6 years ago

image

但是使用 node 的 REPL 运行 markdown-it 再加上两个插件是能够渲染出来的。

image

wafer-li commented 6 years ago

package.json 信息:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "markdown-it": "^8.4.0",
    "markdown-it-footnote": "^3.0.1",
    "markdown-it-katex": "^2.0.3"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

node REPL 重现步骤:

var md = require('markdown-it')()
var tex = require('markdown-it-katex')
var foot = require('markdown-it-footnote')

md.use(tex)
md.use(foot)

md.render('$a+b$')
md.render('hehe[^1]\n[^1]: asddasjhf')
md.render('hehe[^1]\n[^1]: $a+b$')
wafer-li commented 6 years ago

md 原始文档

footnote[^1]

[^1]: $a+b$

相关的目录结构 image

同时尝试了更新 markdown-it 到最新版本也未能解决。

CHENXCHEN commented 6 years ago

使用该插件在本地测试,结果是有渲染正常的。 如下图: image

image

wafer-li commented 6 years ago

不是 hexo-all-minifier 的原因

image

image

是我哪里配置错了吗? 

CHENXCHEN commented 6 years ago
  1. 可以把 hexopackage.json 贴出来吗?
  2. _config.yml 中的配置看起来没有问题
wafer-li commented 6 years ago
{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "hexo": {
    "version": "3.4.4"
  },
  "dependencies": {
    "hexo": "^3.4.4",
    "hexo-all-minifier": "^0.4.1",
    "hexo-deployer-git": "^0.3.1",
    "hexo-filter-plantuml": "^1.0.1",
    "hexo-generator-archive": "^0.1.5",
    "hexo-generator-atom-markdown-writer-meta": "^0.1.1",
    "hexo-generator-category": "^0.1.3",
    "hexo-generator-feed": "^1.2.0",
    "hexo-generator-index": "^0.2.0",
    "hexo-generator-searchdb": "^1.0.8",
    "hexo-generator-seo-friendly-sitemap": "0.0.21",
    "hexo-generator-tag": "^0.2.0",
    "hexo-inject": "^1.0.0",
    "hexo-reference": "^1.0.3",
    "hexo-renderer-ejs": "^0.3.1",
    "hexo-renderer-markdown-it-plus": "^1.0.2",
    "hexo-renderer-stylus": "^0.3.1",
    "hexo-server": "^0.3.1",
    "hexo-symbols-count-time": "^0.2.0",
    "markdown-it-task-lists": "^2.1.0"
  }
}

~hexo-filter-plantuml 这个是我写的,我先删掉试试看,排除一下个人原因。~ 不是这个插件的原因。

CHENXCHEN commented 6 years ago

可以将 _config.yml 中完整的内容贴下吗? 当然一些隐秘的比如密钥链接之类的可以删去

CHENXCHEN commented 6 years ago

我创建个 demo 项目供你参考下吧。。几分钟

wafer-li commented 6 years ago

好的。不过我使用的是 Data File 里面的 config。

目前 Hexo 可以在生成和部署的时候自定义 config 文件。

具体来说就是把根目录的 config 和主题里面的 config 合在一起,然后这个新的 config 会优先读取。

我的配置文件在这里 https://pastebin.com/2fL1gdxM

CHENXCHEN commented 6 years ago

尝试下将 50~51 行的 true 改为 false

wafer-li commented 6 years ago

不行 image

image

wafer-li commented 6 years ago

不如把你的 config 发上来,我去 diff 一下吧

2018年1月15日 19:14,"Wafer Li" notifications@github.com写道:

不行 [image: image] https://user-images.githubusercontent.com/12459199/34939837-9a15c328-fa30-11e7-82d7-116dca630265.png

[image: image] https://user-images.githubusercontent.com/12459199/34939849-a9e94518-fa30-11e7-8a49-ba2542a31f8d.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus/issues/6#issuecomment-357653621, or mute the thread https://github.com/notifications/unsubscribe-auth/AL4cv0nNUr-vIrxv2p2ou2cbTj0PsYTNks5tKzMOgaJpZM4ReLiK .

CHENXCHEN commented 6 years ago

参考 hexo-blog-demo

wafer-li commented 6 years ago

好的,我回去研究一下。

wafer-li commented 6 years ago

修好了,估计是我之前的配置写的有毒。

目前是把所有的自定义配置都写在原来的下面,然后就没问题了。

给一个 diff 参考一下:

https://github.com/wafer-li/wafer-li.github.io/pull/3/files#diff-b0ca4ccbaf3d7058b5a8d76a7c67eee1

wafer-li commented 6 years ago

我建议你赶紧把 demo 删掉…… https://github.com/CHENXCHEN/hexo-blog-demo/blob/master/themes/next/_config.yml#L426

leancloud 目前好像有安全风险。 https://github.com/theme-next/hexo-theme-next/issues/25

CHENXCHEN commented 6 years ago

Thanks