GeekaholicLin / hexo-theme-ylion

:blush: 说不定是一个让你感到惊喜的hexo主题 :beers: :candy:
http://blog.geekaholic.cn
MIT License
120 stars 30 forks source link

Markdown 連結以半形右括號結尾,連結會無法正常解析 #28

Closed mosdeo closed 7 years ago

mosdeo commented 7 years ago

比如連結字串是這樣

那 render 出來 html 的連結就是這樣

GeekaholicLin commented 7 years ago

有没有线上具体的例子?

mosdeo commented 7 years ago

我原本踩的雷先用 HTML 解決了,剛剛弄了個栗子

原文 Markdown source

GeekaholicLin commented 7 years ago

这目测与主题无关,我使用hexo-renderer-pandoc渲染引擎,成功渲染。 不知道你的package.json文件的dependencies字段都安装了哪些包。(为了近一步地调试,你可以发在这个issue中) 你可以尝试一下将你目前的markdown渲染插件卸载,然后运行npm install hexo-renderer-pandoc --save进行安装,当然,前提是你的电脑需要安装pandoc

以下是我本地环境的渲染结果:

image

mosdeo commented 7 years ago

以下是我的package.json,正在嘗試你說的替換 render

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "hexo": {
    "version": "3.3.8"
  },
  "dependencies": {
    "ejs": "^1.0.0",
    "hexo": "^3.2.0",
    "hexo-autoprefixer": "^1.0.0",
    "hexo-deployer-git": "^0.3.1",
    "hexo-generator-archive": "^0.1.4",
    "hexo-generator-category": "^0.1.3",
    "hexo-generator-feed": "^1.2.0",
    "hexo-generator-index": "^0.2.0",
    "hexo-generator-json-content": "^3.0.1",
    "hexo-generator-search": "^2.1.1",
    "hexo-generator-sitemap": "^1.2.0",
    "hexo-generator-tag": "^0.2.0",
    "hexo-pagination": "^0.1.0",
    "hexo-renderer-ejs": "^0.3.1",
    "hexo-renderer-jade": "^0.3.0",
    "hexo-renderer-less": "^0.2.0",
    "hexo-renderer-marked": "^0.3.0",
    "hexo-renderer-sass": "^0.3.2",
    "hexo-renderer-stylus": "^0.3.1",
    "hexo-server": "^0.2.0",
    "hexo-util": "^0.6.1",
    "moment": "^2.18.1",
    "utils-merge": "^1.0.0"
  }
}
GeekaholicLin commented 7 years ago

请将这个先卸载哈。

hexo uninstall hexo-renderer-marked --save

mosdeo commented 7 years ago

我動作太急燥,結果現在 GG 了

你給我上一個回應之前,說要把「markdown渲染插件卸载」,然後我就把以下這些都 uninstall 了

    "hexo-renderer-ejs": "^0.3.1",
    "hexo-renderer-jade": "^0.3.0",
    "hexo-renderer-less": "^0.2.0",
    "hexo-renderer-marked": "^0.3.0",
    "hexo-renderer-sass": "^0.3.2",
    "hexo-renderer-stylus": "^0.3.1",

結果,現在不管下什麼 hexo 指令都會出這個錯:

INFO  Start processing
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn pandoc ENOENT
    at exports._errnoException (util.js:1020:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

好像是 pandoc 的問題?但是安裝 pandoc 也不成功

$ npm install pandoc
hexo-site@0.0.0 /home/lky/workspace/mosdeo.github.io
└── pandoc@0.2.0 

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
GeekaholicLin commented 7 years ago

把你误卸载的插件都复制到package.json文件中,然后npm install重新安装一遍就好了。

问题在于你安装pandoc的方式错误,还请到官网中查看安装方式~

http://pandoc.org/installing.html

mosdeo commented 7 years ago

感謝,我換回原 render 之後先暫時正常。但是換到 pandoc 以後就這樣了

$ hexo g
INFO  Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: [pandoc warning] YAML header is not an object "source" (line 56, column 1)

    at ChildProcess.<anonymous> (/home/lky/workspace/mosdeo.github.io/node_modules/hexo-renderer-pandoc/index.js:73:20)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:891:16)
    at Socket.<anonymous> (internal/child_process.js:342:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:497:12)

查一下可能和內文格式不合有關,所以我想說先把文章全部移出 _posts 看看,結果換了另一個錯誤:

$ hexo g
INFO  Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Template render error: (unknown path) [Line 7, Column 23]
  Error: Unable to call `the return value of (posts["first"])["updated"]["toISOString"]`, which is undefined or falsey
    at Object.exports.prettifyError (/home/lky/workspace/mosdeo.github.io/node_modules/nunjucks/src/lib.js:34:15)
    at /home/lky/workspace/mosdeo.github.io/node_modules/nunjucks/src/environment.js:486:31
    at new_cls.root [as rootRenderFunc] (eval at _compile (/home/lky/workspace/mosdeo.github.io/node_modules/nunjucks/src/environment.js:565:24), <anonymous>:161:3)
    at new_cls.render (/home/lky/workspace/mosdeo.github.io/node_modules/nunjucks/src/environment.js:479:15)
    at Hexo.module.exports (/home/lky/workspace/mosdeo.github.io/node_modules/hexo-generator-feed/lib/generator.js:28:22)
    at Hexo.tryCatcher (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/util.js:16:23)
    at Hexo.<anonymous> (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/method.js:15:34)
    at /home/lky/workspace/mosdeo.github.io/node_modules/hexo/lib/hexo/index.js:340:24
    at tryCatcher (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/util.js:16:23)
    at MappingPromiseArray._promiseFulfilled (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/map.js:61:38)
    at MappingPromiseArray.PromiseArray._iterate (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/promise_array.js:114:31)
    at MappingPromiseArray.init (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/promise_array.js:78:10)
    at MappingPromiseArray._asyncInit (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/map.js:30:10)
    at Async._drainQueue (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/home/lky/workspace/mosdeo.github.io/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

因為以上狀況,目前還無法用 hexo-renderer-pandoc

這篇也是類似狀況,但我沒有像他解決的這麼順利 http://sean10.github.io/2017/07/01/%E6%9B%B4%E6%8D%A2markdown%E6%B8%B2%E6%9F%93%E5%BC%95%E6%93%8E/

GeekaholicLin commented 7 years ago

后一个错误可以看这个issue

https://github.com/iissnan/theme-next-docs/issues/79

是因为_post中没有文章导致的。

至于第一个错误,应该是你所说的格式错误。如果你的文章量不是很大,可以进行你给我的链接所说的,二分法排除。(先移出一半的文章,进行hexo g看是否有错误,不懂进行)。如果你的文章量很大,导致难以定位和修改,我建议还是使用之前的渲染插件。

至于之前的渲染插件怎么解决渲染错误问题,可以在遇到你要在链接中使用()的时候,使用html标签,或者你可以到hexo-renderer-marked官方repo提出相关issue,看是否能得以解决。

mosdeo commented 7 years ago

感謝,render 問題最後還是換成 pandoc 一篇篇修改解決了。