Code Monkey home page Code Monkey logo

hexo-renderer-pandoc's Introduction

hexo-renderer-pandoc

npm npm

Yet another markdown renderer plugin for Hexo. It can convert Pandoc's markdown to HTML. If you want, it can also be a renderer for textile, reStructedText, etc.

Installation

  1. Firstly, make sure you have installed pandoc (version >= 2.0).
  2. Secondly, cd into your hexo root folder and execute the following command:
$ npm install hexo-renderer-pandoc --save

This will install hexo-renderer-pandoc.

Customization

By default, this plugin issues command pandoc to invoke pandoc. If your pandoc executable is not in your search path environment variable, you can override this command through _config.yml.

pandoc:
  pandoc_path: C:/Program Files/Pandoc/pandoc.exe

Using absolute path is recommended.

The path depends on your operating system. So even if you are using the git-bash shell on Windows, you need the Windows path like the one in the example.

You can pass arguments to pandoc through _config.yml as an array:

pandoc:
  args:
    - arg1
    - arg2
    - arg3

or in another style:

pandoc:
  args: [arg1, arg2, arg3]

You may need to quote each argument with quotation marks according to YAML syntax specification. If in doubt, quote all arguments.

Note: a Pandoc key-value arguments --key value need to be separated as two arguments

pandoc:
  args: [..., "-key", "value", ...]

A minimal working example that render HTML from markdown:

pandoc:
  args:
    - "-f"
    - "markdown"
    - "-t"
    - "html"
    - "--mathjax"

The extension automatically adds the following arguments:

[
  "-M",
  "pagetitle=dummy",
  <arguments you specified>,
  "-M",
  "standalone=[True|False]",
]

where pagetitle specifies a dummy title to make Pandoc happy; the actual title is handled by Hexo. And see the Standalone Value in Pandoc Filters section for the meaning of the standalone value.

There exists another interface for specifying arguments prior to version v4.0. See here for the old documentation on its behaviour. The interface is preserved for backward compatibility but will not be supported due to its lack of flexibility.

Using Pandoc Filters

We welcome adding your Pandoc filters to this section! We encourage developing filters in Lua as they can be executed by Pandoc (v 5.4) directly without the need of setting up external interpreter and libraries. See Pandoc Lua Filters

  • (lua) header link (@moon-jam)

    This filter add links to headers as hexo-renderer-marked does. Many themes depend on this behavior to show the anchor icon. see issue #59

Issues related to Hexo Tags ##_

There are issues related to Hexo tags. If you are using them, this section may be at your concern.

Here we are referring to this sort of tags, not post tags

Mechanism of Tag Rendering

This function takes care of post rendering.

The rendering of a post takes the following steps:

  1. Since Swig Tags (things like {% %}) are not part of legal Markdown, all Swig Tags are "escaped", i.e., extracted from the post and each replaced with a unique marker.

  2. The post, now contains only legal Markdown, is rendered without any tag, by calling this plugin.

  3. Tags are separately rendered as Markdown, also by calling this plugin.

  4. Rendered tags are inserted back to the post, each to the position of its unique marker.

Note tags can be nested.

Issues arise as tags are rendered with separate calls to this plugin. One being when using Pandoc templates to add header/footer, we only want the template to be used if we are rendering a post. An other similar issue is some Pandoc filters also needs to know whether they are rendering a standalone post, or just a fragment.

Since Hexo calls this plugin without telling whether it want us to render a standalone post, we attempt to figure this out ourselves. Looking at the source code of Hexo, we found that if we are rendering a post, data has the key path , otherwise (e.g., rendering a tag), path is not present in data . We are currently only aware of one situation when we are not rendering a standalone post, i.e., when we are rendering a tag.

What to be Aware of when Using Tags

Templates

Currently templates are only applied when rendering standalone posts. If there is any need to also apply templates (possibly a different set applied to posts) to tags, please submit an issue report to request this functionality, we'd be happy to discuss on how it should behave and implement it.

Footnotes

Due to how tags are rendered, content of each tag has its own "scope". When rendering a tag, Pandoc sees neither other tags contained in it, nor the context where it is contained. One implication of which is when using footnotes, one has to be aware of that a footnote reference and its definition has to be in the same tag. Even when one thing is in the tag nested in where the other is, is illegal.

For example, the following is illegal.

{% tag %}
[^1]
{% tag %}
[^1]: definition of footnote 1
{% endtag%}
{% endtag%}

The following is legal, as all three definitions are in different scopes.

{% tag %}
[^1]
{% tag %}
[^1]
[^1]: definition of footnote 1
{% endtag%}
[^1]: definition of footnote 1
{% endtag%}

{% tag %}
[^1]
[^1]: definition of footnote 1
{% endtag%}

The standalone value in Pandoc Filters

we passed the argument -M standalone=[True|False] to Pandoc. If a Pandoc Filter desires to know whether it is applied to a standalone post, it can check the metavariable standalone.

As an example, when using Panflute, this metavariable can be accessed by

doc.get_metadata("standalone", True)

We recommend to assume rendering standalone post when this metavariable is not set for backward compatibility.

Credits

I'd like to thank John MacFarlane for creating Pandoc and John Gruber for developing Markdown. Also, this work is based on @pvorb (Paul Vorbach) 's node-pdc wrapper for pandoc.

Special credit for @Ritsuka314 as a good maintainer for this project!

hexo-renderer-pandoc's People

Contributors

alexpnt avatar fredhdx avatar haozeke avatar matchachoco010 avatar megrezzhu avatar moon-jam avatar ritsuka314 avatar uiolee avatar wzpan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hexo-renderer-pandoc's Issues

how to get metadata?

Hi, I have this source in rST:

title: 'Oh, really?'                                                            
categories:                                                                     
  - computer                                                                    
date: 2011-03-29 07:54:00                                                       
tags:                                                                           
---                                                                             

.. image:: http://1.bp.blogspot.com/-FicWNUhziTc/TZFzFKHBfqI/AAAAAAAAAv4/zB2N6X-B2sc/s1600/spreadfirefox.png
    :scale: 66%                                                                 
    :align: center                                                              

So, `spreadfirefox.com`_ which is known to be a PR tool of the Firefox          
community proudly offers old version of Firefox? (fortunately, these            
buttons lie, it really leads to firefox.com which offers the real               
thing). Interesting.                                                            

.. _`spreadfirefox.com`:                                                        
    http://www.spreadfirefox.com/                                               

Pure generation of HTML works just fine, but I don't know how to make hexo to get proper metadata (pariclarly it makes post dated by the date it has been generated, not the date mentiond in the date: field). It seems your renderer just runs the text through pandoc, but it doesn'ŧ seem to be parsing metadata from anywhere.

Error: spawn pandoc ENOENT

Hi, I install Pandoc with cabal and then add its path to system path. There is no problem when I run Pandoc in terminal. But when I run hexo g, there is some error:

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: spawn pandoc ENOENT
    at exports._errnoException (util.js:837:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at doNTCallback2 (node.js:429:9)
    at process._tickCallback (node.js:343:17)

numbered section not working + table width problem

Q1.
Hi I am trying to turn on the numbered section option supported by native pandoc with this plugin.

I set the config file as

pandoc:
    extra:
        -number-sections: true

I expected it to be passed as --number-sections to pandoc and in html show

1. Header1
2. Header2
    2.1 Sub-header1

But I don't see the generated html having section headers numbered. I tried to put numbersections: true in the .md's front matter as well. The {-} function to not number a section didn't work either.

Q2.
Also, I created a multiline table using pandoc's syntax. The table width however only extends to the number of dashes I have in the markdown file. The relative width works. Is it possible to make pandoc adopt the full width of the section while still maintain the relative width?

Thank you.

about env of pandoc

I see :

var res = spawnSync("pandoc", args, {
   cwd: process.cwd(),
   env: process.env,
   encoding: "utf8",
   input: src
 });

could I use config like "env: /path/pandoc" and use the pandoc that is located in the certain path:

var res = spawnSync(config.env, args, {
   cwd: process.cwd(),
   env: process.env,
   encoding: "utf8",
   input: src
 });

高版本的未知兼容问题

pandoc-2.7.1WIN10环境中 hexo-renderer-pandoc 的0.2.4及其以上版本出现未知问题。DEMO是在pandoc-2.7.1[email protected]下生成的。

SITE'S _config.yml:

  
pandoc:
  filters:
  extra:
  template: 
  meta:
  mathEngine:
  1. 安装 npm install [email protected] --save 版本,部分渲染丢失和失效。

丢失:

image

源MD文件:

Pandoc is a universal document converter!对 md 扩展支持让我拜倒,例如[脚注的支持](http://pandoc.org/MANUAL.html#footnotes)部分。需要提醒的是:pandoc 渲染器对 md 的格式要求更加规范些,例如 链接需要用`< >`括号显式包含;quoteblock 每行必须跟两空格表示换行(如果后续行没有`>`标记的话)。当然,把 [Pandoc’s Markdown](http://pandoc.org/MANUAL.html#pandocs-markdown) 浏览一下是很有必要的,或者 [pdf 版本](http://pandoc.org/MANUAL.pdf)。

1. 第二种方法,使用Pandoc渲染器:

    在文件`/layout/_layout.swig`中`/body`前加入:

    ```
    <script type="text/javascript" src="/js/custom.js"></script>
    ```

    在`/themes/next/source/js`中添加文件`custom.js`,在`custom.js`中添加

    ```
    // 函数: html 中去掉 某 tag 最后那一次出现
    var rmLastElm = function(text, selector) {
        var wrapped = $("<div>" + text + "</div>");
        wrapped.find(selector).last().remove();
        return wrapped.html();
    }
    // 弹出 tip 显示 脚注
    var $fRef = $(".footnoteRef");
    for(let i=0; i<$fRef.length; i++) {
    	var sup = $fRef.children("sup")[i];		//work reliably as long as there's exactly one sup per footnotRef
    //	var sup = $fRef[i].children("sup");		//a classic Dom Element, so it doesn't have any children method
    	sup.onmouseover = function(event) {
    		$('.footnoteTip').remove();
    		var pTip = document.createElement('div');
    		pTip.className = 'footnoteTip';		// CSS
    		pTip.innerHTML = rmLastElm(document.getElementById($fRef[i].getAttribute("href").substring(1)).innerHTML,"a");
    		document.body.appendChild(pTip);

    		var posLeft = event.pageX - 180;
    		if (posLeft<0) posLeft = 20;
    		var posTop = event.pageY + 20;
    		var od = $('.footnoteTip');
    		var oH = od.outerHeight();
    		var oW = od.outerWidth();
    		if(posTop + oH - window.pageYOffset > $(window).height()) 	posTop = posTop - oH -40;
    		if (posLeft + oW > $(window).width()) posLeft = $(window).width() - oW -20;	//NexT.Mist pageXOffset=0
    		pTip.style.left = posLeft + 'px';
    		pTip.style.top = posTop + 'px';

    	};

    	sup.onmouseout = function(event) {
    		$('.footnoteTip').remove();
    	};
    }
    ```

## 外链播放器

部分 HEXO tags 失效:

image

源MD文件:

## Quick Start

{% tabs First unique name %}
<!-- tab -->
**This is Tab 1.**
<!-- endtab -->
<!-- tab -->
**This is Tab 2.**
<!-- endtab -->
<!-- tab -->
**This is Tab 3.**
<!-- endtab -->
{% endtabs %}
  1. 安装 npm install [email protected] --save 或者更高版本,出现未知问题
Administrator@DESKTOP-ALEX MINGW64 /f/alex/hexo (gh-pages)
$ hexo clean && hexo g && hexo s
INFO  Deleted database.
INFO  Deleted public folder.
INFO  Start processing
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: write EOF
    at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)

Unexpected Changes in Article Headerlink and Missing Headerlink Icon

After installing hero-renderer-pandoc and uninstalling hexo-renderer-marked, I've noticed some unexpected behavior in my articles. The URLs for the article Header have been altered (such as an article titled 'header 123' would generate a URL like this: https://example.com/myarticle/#header-123 originally. However, with the changes, the URL format has been altered to https://example.com/myarticle/#header123) , and the headerlink icons(as shown in the screenshot below) that usually appear at the end of the titles are missing.
image

I would appreciate some guidance on resolving this issue or any insights into what might be causing these changes.

Thank you for your assistance!

hexo g error

After I use
"sudo npm uninstall hexo-renderer-marked --save"
"sudo npm install hexo-renderer-pandoc --save"

and then type:
hexo clean
hexo g

It report this error:

Error: 
[ERROR][hexo-renderer-pandoc] On /Users/user/Documents/GitHub/ChrAlpha/aiguosb/source/_posts/p0-关于域名的测试.md
[ERROR][hexo-renderer-pandoc] pandoc exited with code null.
    at Hexo.pandocRenderer (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/hexo-renderer-pandoc/index.js:112:11)
    at Hexo.tryCatcher (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/util.js:16:23)
    at Hexo.<anonymous> (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/method.js:15:34)
    at Promise.then.text (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/hexo/lib/hexo/render.js:60:20)
    at tryCatcher (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromiseCtx (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/promise.js:611:10)
    at _drainQueueStep (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/async.js:142:12)
    at _drainQueue (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/user/Documents/GitHub/ChrAlpha/aiguosb/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

I have removed the
if (config && config.template) { args.push("--template=" + config.template); }
in
node_modules/hexo-renderer-pandoc/index.js

but it still didn't work...

After installing the package, I haven't changed the ROOT _config.yml or nexT _config.yml, except for the math: enable: true and mathjax: enable: true

Publish 0.2.7 on npm

Turned out that my fixes 947ea9d and d2c7636 included in 0.2.6 would fail on mac and unix due to different EOL sequences used on those two systems. As part of the fix at 2042bb5, this issue is solved. @wzpan could you please publish it (0.2.7) to npm? Thanks a lot.

It does not work with hexo 3.0

I got the error information as below when I run the command 'hexo generate'

/home/orangeclk/blog/node_modules/hexo-renderer-pandoc/index.js:20
error += data();
^
TypeError: object is not a function
at Socket. (/home/orangeclk/blog/node_modules/hexo-renderer-pandoc/index.js:20:12)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket. (stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable
(_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at Pipe.onread (net.js:526:21)

The environment is:
hexo: 3.0.0
os: Linux 3.16.0-24-generic linux x64
http_parser: 1.0
node: 0.10.25
v8: 3.14.5.9
ares: 1.10.0
uv: 0.10.23
zlib: 1.2.8
modules: 11
openssl: 1.0.1f

How to new a line with Enter?

I wonder how to new a line with ENTER in hexo-renderer-pandoc?
I used to write my blog with the style that new a line with ENTER.
But recently I update my hexo-theme-next theme, it now support hexo-renderer-pandoc for the Mathjax.
When I switch my hexo renderer to pandoc, I find that making a newline need two space and one break.
It is cumbersome to change my Blog source code. Therefore, can you help me customize hexo-renderer-pandoc to support making newline with ENTER?
Thanks!

`hexo-renderer-pandoc` with `hexo-generator-feed` produces HTML generation errors | `hexo-renderer-pandoc` 搭配 `hexo-generator-feed` 会出现 HTML 生成错误

Problem Description 问题描述

Rendering with hexo-renderer-pandoc and using hexo-generator-feed plugin generates RSS feed link, when it encounters too long text in a line and a link appears in this line, it will cause an error in the generated HTML.

在使用 hexo-renderer-pandoc 渲染并使用 hexo-generator-feed 插件生成 RSS 订阅链接时,当遇到一行之中过长的文字,且该行出现链接时,会导致生成出的 HTML 出现错误。

For example, the original text of my Markdown is as follows:

如我的 Markdown 原文如下:

[test](https://012345678901234567890123456789012345678)

In the generated RSS subscription text, the content in the <content> field is

在生成出的 RSS 订阅文本中,<content> 字段中内容为

<content type="html"><![CDATA[<p><ahref="https://012345678901234567890123456789012345678">test</a></p>]]></content>

You can see that there is no space between <a and href, which causes a rendering error.

可以看到 <ahref 之间没有空格,从而导致渲染错误。

This problem does not occur on normal blog pages.

该问题在正常博客页面不会出现。

Since this problem does not occur when using Hexo's default renderer hexo-renderer-marked, an issue is raised under this repository.

由于使用 Hexo 默认渲染器 hexo-renderer-marked 不会出现该问题,故在该仓库下提起 issue。

Reproduction Steps 复现步骤

My Hexo version information 我的 Hexo 版本信息:

hexo: 6.3.0
hexo-cli: 4.3.0
os: win32 10.0.19044
node: 18.8.0
v8: 10.2.154.13-node.11
uv: 1.43.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.18.1
modules: 108
nghttp2: 1.47.0
napi: 8
llhttp: 6.0.7
openssl: 3.0.5+quic
cldr: 41.0
icu: 71.1
tz: 2022a
unicode: 14.0
ngtcp2: 0.1.0-DEV
nghttp3: 0.1.0-DEV

Node.js version is v18.8.0

npm version is 8.18.0

pandoc version 3.1.2

Follow the steps below to reproduce the problem step by step 按照下面步骤逐步执行即可复现该问题

$ hexo init test
$ cd test
$ npm uninstall hexo-renderer-marked
$ npm install hexo-renderer-pandoc --save
$ npm install hexo-generator-feed
$ hexo new test

Insert the Markdown into the source/_post/test.md file

将刚才的 Markdown 插入 source/_post/test.md 文件中

---
title: test
date: 2023-04-01 15:34:17
tags:
---

[test](https://012345678901234567890123456789012345678)

Save and quit.

保存并退出。

Modify the configuration to make hexo-generator-feed take effect, add the following content to _config.yml

修改配置使 hexo-generator-feed 生效,向 _config.yml 中添加

feed:
  enable: true
  type: atom
  path: atom.xml

And then, generate! 然后,生成

$ hexo g

The generated code can be seen in public/atom.xml

可以在 public/atom.xml 下看到生成的代码

<entry>
    <title>test</title>
    <link href="http://example.com/2023/04/01/test/"/>
    <id>http://example.com/2023/04/01/test/</id>
    <published>2023-04-01T07:34:17.000Z</published>
    <updated>2023-04-01T07:47:15.742Z</updated>
    
    <content type="html"><![CDATA[<p><ahref="https://012345678901234567890123456789012345678">test</a></p>]]></content>

    <summary type="html">&lt;p&gt;&lt;a
href=&quot;https://012345678901234567890123456789012345678&quot;&gt;test&lt;/a&gt;&lt;/p&gt;
</summary>

  </entry>

This is really an April Fool's Day joke for me, but this issue is not an April Fool's Day joke.

Can I set the resource root path?

I use typora to write md file.

When I insert picture in my article xxx.md, typora will create a directory named xxx and put picture in it, then insert in my article.

When I used hexo-renderer-marked, I can write following config to make it generate the web page with picture url like http://example.com/xxx/yyy.png.

post_asset_folder: true
marked:
  prependRoot: true
  postAsset: true

However, I have not found a way to set hexo-renderer-pandoc to use such a resource url. Now it generate the web page with picture url live http://example.com/xxx/xxx/yyy.png (a wrong path).

Now I use hexo-asset-img to solve it temporarily

Error handling tag id assignment through pandoc syntax

In pandoc we can assign id to a generated html tag by

:::{#id-of-tag}
Content of this block
:::

However, this can not be rendered correctly. Actaully, content after this block is truncated. This is obvious caused by nunjuncks compatibility, where {# #} is a valid block. To be more specific, in hexo/lib/hexo/post.js, if disableNunjucks is not set, then the content of the post will be processed in the following way:

if (disableNunjucks === false) {
    data.content = cacheObj.escapeAllSwigTags(data.content);
}

Thus the content after {# is truncated (It will try to find the coresponded #} till the end of the post). To address this problem, you need to do two things:

  • In hexo-renderer-pandoc, make sure you set pandocRenderer.disableNunjucks = true
  • Upgrade hexo to 7.0.0. If you still using hexo 6.x.x, you need to fix a bug manually by editting hexo/lib/extend/renderer.js . Find register method of class Renderer and make sure it looks like this:
  register(name, output, fn, sync) {
    if (!name) throw new TypeError('name is required');
    if (!output) throw new TypeError('output is required');
    if (typeof fn !== 'function') throw new TypeError('fn must be a function');

    name = getExtname(name);
    output = getExtname(output);

    if (sync) {
      this.storeSync[name] = fn;
      this.storeSync[name].output = output;
      this.store[name] = Promise.method(fn);
    } else {
      if (fn.length > 2) fn = Promise.promisify(fn);
      this.store[name] = fn;
    }

    this.store[name].output = output;
    this.store[name].compile = fn.compile;
    this.store[name].disableNunjucks = fn.disableNunjucks;  // <--- this is the added line!
  }
}

关于 \newcommand 的问题

如果我写

$$
\newcommand{\lcm}{\operatorname{lcm}}
\newcommand{\type}{\text{type}}
\newcommand{\ffrac}[2]{\left\lfloor\frac{#1}{#2}\right\rfloor}
\prod_{i=1}^{A}\prod_{j=1}^{B}\prod_{k=1}^{C}\left(\frac{\lcm(i,j)}{\gcd(i,k)}\right)^{f(\type)} = \prod_{i=1}^{A}\prod_{j=1}^{B}\prod_{k=1}^{C}\left(\frac{ij}{\gcd(i,j)\gcd(i,k)}\right)^{f(\type)}
$$

的话会报错为

$ 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)
  Error: expected end of comment, got end of file
    at Object._prettifyError (D:\blog\node_modules\nunjucks\src\lib.js:36:11)
    at Template.render (D:\blog\node_modules\nunjucks\src\environment.js:526:21)
    at Environment.renderString (D:\blog\node_modules\nunjucks\src\environment.js:364:17)
    at D:\blog\node_modules\hexo\lib\extend\tag.js:62:48
    at tryCatcher (D:\blog\node_modules\bluebird\js\release\util.js:16:23)
    at Function.Promise.fromNode.Promise.fromCallback (D:\blog\node_modules\bluebird\js\release\promise.js:180:30)
    at Tag.render (D:\blog\node_modules\hexo\lib\extend\tag.js:62:18)
    at Object.onRenderEnd (D:\blog\node_modules\hexo\lib\hexo\post.js:282:20)
    at D:\blog\node_modules\hexo\lib\hexo\render.js:65:19
    at tryCatcher (D:\blog\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\blog\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (D:\blog\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (D:\blog\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (D:\blog\node_modules\bluebird\js\release\promise.js:694:18)
    at _drainQueueStep (D:\blog\node_modules\bluebird\js\release\async.js:138:12)
    at _drainQueue (D:\blog\node_modules\bluebird\js\release\async.js:131:9)
    at Async._drainQueues (D:\blog\node_modules\bluebird\js\release\async.js:147:5)
    at Immediate.Async.drainQueues (D:\blog\node_modules\bluebird\js\release\async.js:17:14)
    at processImmediate (internal/timers.js:456:21)

删掉 \newcommand 然后手动替换就可以了?请问如何解决?

[Solved]citations can not be rendered

I have installed hexo-renderer-pandoc, and followed the tutorial in Readme.md.


Problem

However, the citation can't show as excepted. ( Cf. §Conclusion on page http://bitwan.science/2015/10/21/ch2-1-9-Changing-the-case-geometry/ )

I read a lot of your Chinese Blog, and knew that hexo-renderer-pandoc may not work well with hexo 3.0. However, I am just using Hexo 3.1.1.

My Configuration

  • My working environment is as bellow:
hexo 3.1.1
pandoc 1.15.0.6
pandoc-citeproc 0.7.2
  • The configuration involving hexo-renderer-pandoc is :
pandoc:
  filters:
    - pandoc-citeproc
  extra:
    - bibliography: "/path/to/bibfile.bib"

How to preserve tabs in code blocks?

For pandoc, the command line option --preserve-tabs makes pandoc preserve tabs in code blocks when converting markdown to HTML. I tried to pass that option to pandoc use by hexo-renderer-pandoc in the following ways:

Adding it to _config.yaml

pandoc:
  extensions:
    - -implicit_figures
    - +gfm_auto_identifiers+angle_brackets_escapable # Not available in pandoc 1.16
    - +pipe_tables+raw_html+fenced_code_blocks
    - -ascii_identifiers+backtick_code_blocks+autolink_bare_uris
    - +intraword_underscores+strikeout+hard_line_breaks+emoji
    - +shortcut_reference_links
  extra:
    - preserve-tabs

Adding it to node_modules/hexo-renderer-pandoc/index.js

  args.push("--preserve-tabs");

  var res = spawnSync('pandoc', args, {
    cwd: process.cwd(),
    env: process.env,
    encoding: "utf8",
    input: src
  });

But neither of them works. After hexo s -g, the generated blog page still replaces each tab with four whitespaces. So I'm wondering how to preserve tabs in code blocks for hexo-renderer-pandoc.

嵌套的tag渲染错误

当在tag中嵌套了其他tag时,如下面这个markdown文本(来自NexT的官方文档):

{% tabs Tags %}
<!-- tab -->
**This is Tab 1.**

1. One
2. Two
3. Three

4-spaces code block:

    nano /etc

Tagged code block:

{% code %}
code tag
code tag
code tag
{% endcode %}

{% note default %}
Note default tag.
{% endnote %}
<!-- endtab -->

<!-- tab -->
**This is Tab 2.**

* Five
* Six
* Seven

{% note primary %}
{% youtube Kt7u5kr_P5o %}
{% endnote %}
<!-- endtab -->

<!-- tab -->
**This is Tab 3.**

{% subtabs Sub Tabs %}
<!-- tab -->
**This is Sub Tab 1.**
{% note success %}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti. Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.

{% note warning %}
Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.
{% endnote %}

Morbi interdum mollis sapien. Sed ac risus. Phasellus lacinia, magna a ullamcorper laoreet, lectus arcu pulvinar risus, vitae facilisis libero dolor a purus. Sed vel lacus. Mauris nibh felis, adipiscing varius, adipiscing in, lacinia vel, tellus. Suspendisse ac urna. Etiam pellentesque mauris ut lectus. Nunc tellus ante, mattis eget, gravida vitae, ultricies ac, leo. Integer leo pede, ornare a, lacinia eu, vulputate vel, nisl.
{% endnote %}
<!-- endtab -->

<!-- tab -->
**This is Sub Tab 2.**
{% note success %}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti. Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.

Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.

{% note danger %}
Morbi interdum mollis sapien. Sed ac risus. Phasellus lacinia, magna a ullamcorper laoreet, lectus arcu pulvinar risus, vitae facilisis libero dolor a purus. Sed vel lacus. Mauris nibh felis, adipiscing varius, adipiscing in, lacinia vel, tellus. Suspendisse ac urna. Etiam pellentesque mauris ut lectus. Nunc tellus ante, mattis eget, gravida vitae, ultricies ac, leo. Integer leo pede, ornare a, lacinia eu, vulputate vel, nisl.
{% endnote %}
{% endnote %}
<!-- endtab -->

<!-- tab -->
**This is Sub Tab 3.**

{% subtabs Sub-Sub Tabs %}
<!-- tab -->
**This is Sub-Sub Tab 1 of Sub Tab 3.**
{% note success %}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti. Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.

Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.

Morbi interdum mollis sapien. Sed ac risus. Phasellus lacinia, magna a ullamcorper laoreet, lectus arcu pulvinar risus, vitae facilisis libero dolor a purus. Sed vel lacus. Mauris nibh felis, adipiscing varius, adipiscing in, lacinia vel, tellus. Suspendisse ac urna. Etiam pellentesque mauris ut lectus. Nunc tellus ante, mattis eget, gravida vitae, ultricies ac, leo. Integer leo pede, ornare a, lacinia eu, vulputate vel, nisl.
{% endnote %}
<!-- endtab -->

<!-- tab -->
**This is Sub-Sub Tab 2 of Sub Tab 3.**
{% note success %}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti. Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.

{% note warning %}
Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.

Morbi interdum mollis sapien. Sed ac risus. Phasellus lacinia, magna a ullamcorper laoreet, lectus arcu pulvinar risus, vitae facilisis libero dolor a purus. Sed vel lacus. Mauris nibh felis, adipiscing varius, adipiscing in, lacinia vel, tellus. Suspendisse ac urna. Etiam pellentesque mauris ut lectus. Nunc tellus ante, mattis eget, gravida vitae, ultricies ac, leo. Integer leo pede, ornare a, lacinia eu, vulputate vel, nisl.
{% endnote %}

{% endnote %}
<!-- endtab -->

<!-- tab -->
**This is Sub-Sub Tab 3 of Sub Tab 3.**

{% note success %}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti. Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.

{% note warning %}
Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.

{% note danger %}
Morbi interdum mollis sapien. Sed ac risus. Phasellus lacinia, magna a ullamcorper laoreet, lectus arcu pulvinar risus, vitae facilisis libero dolor a purus. Sed vel lacus. Mauris nibh felis, adipiscing varius, adipiscing in, lacinia vel, tellus. Suspendisse ac urna. Etiam pellentesque mauris ut lectus. Nunc tellus ante, mattis eget, gravida vitae, ultricies ac, leo. Integer leo pede, ornare a, lacinia eu, vulputate vel, nisl.
{% endnote %}

{% endnote %}

{% endnote %}
<!-- endtab -->
{% endsubtabs %}

<!-- endtab -->
{% endsubtabs %}

<!-- endtab -->
{% endtabs %}

渲染后就会出现错误:
image
image

返回了源码,并且出现了应该是并列标签的却成了套娃的形式,请问如何处理这个问题?

hexo s error

when use hexo s, something was wrong

[ERROR][hexo-renderer-pandoc] pandoc exited with code 9: pandoc: Unknown extension: smart

Some people on the Internet said that it may be related to Pandoc's smart parameter, which is in the node_modules\hexo-renderer-pandoc\index.js file.

New interface to specify arguments to pandoc

The current interface to specify arguments to pass to pandoc has been causes a few issues:

  • the lack of fine tuning of ordering of the arguments: #43
  • the need for plugin update to support new argument format: #47

Hence it would be ideal to provide a new interface to specify arguments to pandoc, while ideally preserving (but deprecating) backward compatibility.

The task list or todo list cannot be rendered correctly

This is displayed in Typora:
image
And below is what displayed on my website (rendered by hexo-renderer-pandoc):
image

It seems that task list (or called todo list) is not rendered correctly. However, pandoc group stated that it support the task list in their document:
image
And when I run pandoc --list-extensions, I cannot find that extension (task_lists). My pandoc version is 2.2.3.2. Is my pandoc version too old?
Thanks a lot!

Error : conflict between latex and nunjucks

Hi again,
there is a error on the following post:

---
title: Hello World
---

$$\mathbb{{{x}}}$$

This multiple brackets can be include naturally by the use of latex macros with \newcommand allowed by pandoc.

The error is due to nunjucks considering the brackets template tags:

Unhandled rejection Template render error: (unknown path) [Line 1, Column 40]
  parseAggregate: expected colon after dict key
    at Object._prettifyError (/home/user/blog/node_modules/nunjucks/src/lib.js:36:11)
    at Template.render (/home/user/blog/node_modules/nunjucks/src/environment.js:524:21)
    at Environment.renderString (/home/user/blog/node_modules/nunjucks/src/environment.js:362:17)
    at Promise (/home/user/blog/node_modules/hexo/lib/extend/tag.js:66:9)
    at Promise._execute (/home/user/blog/node_modules/bluebird/js/release/debuggability.js:313:9)
    at Promise._resolveFromExecutor (/home/user/blog/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/home/user/blog/node_modules/bluebird/js/release/promise.js:79:10)
    at Tag.render (/home/user/blog/node_modules/hexo/lib/extend/tag.js:64:10)
    at Object.tagFilter [as onRenderEnd] (/home/user/blog/node_modules/hexo/lib/hexo/post.js:230:16)
    at Promise.then.then.result (/home/user/blog/node_modules/hexo/lib/hexo/render.js:65:19)
    at tryCatcher (/home/user/blog/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/user/blog/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/user/blog/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/user/blog/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/user/blog/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/home/user/blog/node_modules/bluebird/js/release/promise.js:638:18)

I propose to disable (or add an option to disable) nunjucks with hexo-renderer-pandoc. There are several known issues with nunjucks. And there is a way to disable it.

We can do it this way : https://github.com/laBecasse/hexo-renderer-pandoc/blob/511e19a162a907f103304e5d0e50aa238ebc70d4/index.js#L95

pandoc 不支持 GFM 格式,转换成 html 失去 [!TIP] 等提示框

Check List

  • I have already read README.
  • I have already searched existing issues.
  • I have already searched existing pull requrests.

Feature Request

pandoc 不支持 GFM 格式,转换成 html 失去 [!TIP] 等提示框

GFM 在typora中是可以正常显示 [!TIP] 等提示框的,但是转换成 html 就显示不好,请问可以改进下吗?

Additional context

No response

Renderer Errors with filter pandoc-citeproc in clean directory

pandoc renderer errors if used with pandoc-citeproc on clean directory

if pandoc renderer is run on hexo generate without filter pages render then render citations if pandoc-citeproc is added to filters in config.yml

The plugin then errors if the directory is cleaned with hexo clean cmd and run again.

Error: pandoc-citeproc: reference undefinedmethod not found
pandoc-citeproc: reference undefinedmethod not found

how to set next's _config.yml when using hexo-next

in version 0.2.1, adding if(config.template) args.push("--template=" + config.template); leads to TypeError: Cannot read property 'template' of undefined when hexo generate...

how to set pandoc in _config.yml, thank you for your help.

pandoc:
  filters:
  extra:
  template:
  meta:
  mathEngine:
  1. mathjax: enable: true in the theme's _config.yml,
  2. npm uninstall hexo-renderer-marked --save
  3. npm install hexo-renderer-pandoc --save
  4. hexo g failed
  5. Remove the if(config.template) args.push("--template=" + config.template); in hexo\node_modules\hexo-renderer-pandoc\index.js ,
  6. hexo g passed

Duplicate note reference problem

hello, npm install [email protected] --save works last time.

but today failed for

INFO  Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: pandoc: Duplicate note reference `1' "source" (line 502, column 1)

    at ChildProcess.<anonymous> (/builds/sli1989/sli1989.gitlab.io/node_modules/hexo-renderer-pandoc/index.js:84:20)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886: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:501:12)
ERROR: Job failed: exit code 1

do u know what's going on?


  • I though it's the problem of footnotes' id. but when i deleted all new footnotes which are added in this commit, it still not work.
  • i tested with old next version, it still not work.

回车换行不起作用

请问能否像hexo-renderer-marked一样支持回车换行,而不是在每句话结尾加上2个以上空格才换行呢?

多级列表转换异常

markdown

1. 离子  
   - 元素种类  
   - 原子数  
   - 原子质量(最大丰度同位素(MAI)质量)  
   - 入射粒子能量范围(最高,最低)  
2. 靶材  
   - 靶材A  
      * 元素种类  
      * 原子数  
      * 原子质量(平均自然质量)  
      * 丰度  
   - 靶材B(可省略)  
   - ...  

期望:
image
实际:
image

[BUG] --smart breaks newer pandoc.

The index.js needs to be modified for pandoc 2

For smart, now the vars should read

var args = [ '-f', 'markdown+smart', '-t', 'html', math]

How to escape dollar signs?

How to escape dollar signs if I don't want math formulas?

Source code:

$math$

\$escaped math\$

\\$double escaped math\\$

Output: All of them are displayed as math formulas. The third one has a backslash at the beginning.

_config.yml:

pandoc:
  args:
    - "-f"
    - "gfm"
    - "-t"
    - "html"
    - "--mathjax"

_config.next.yml:

math:
  mathjax:
    enable: true

readme.md中bibliography前未加-,另外生成的参考文献中没有标题

1,bib遗漏了-

pandoc:
  filters:
    - pandoc-citeproc
  extra:
    bibliography: "/path/to/bibfile.bib"
  1. 可能是pandoc的问题,而非本插件的问题 -___-。
    我设置如下,参考文献正常,但是title无法生成。必须自己在md文件中写入节标题吗?
# hexo-renderer-pandoc
pandoc:
  filters:
    - pandoc-citeproc
  extra:
    - bibliography: "/home/sd44/xueshu/dingjia/ref/refs.bib"
  meta:
    - link-citations: true
    - reference-section-title:“Reference”

3,关于freemind主题的,能否让右侧目录可以随着下拉而滚动?

4,没想到这个包也是wzpan写的,哈哈,一直在用你的主题……

只注册了异步renderer,没有注册同步renderer会导致Hexo的Tag系统渲染出现问题

Hexo的Tag系统在渲染Tag内部内容时,一般都是选择hexo.render.renderSync来渲染内部内容。而hexo-renderer-pandoc在注册renderer时,只注册了异步renderer,因此会导致Tag内的内容无法渲染,输出Markdown源码。

例如,NexT主题中的note Tag的渲染代码为:


function postNote(args, content) {
  return `<div class="note ${args.join(' ')}">
             ${hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join('')}
           </div>`;
}

通过修改Tag的实现代码改成异步渲染可以临时解决这个问题,但是这意味着要修改所有的Tag实现,因此还是希望能够修改一下render的代码,同时注册一下同步渲染。

Why it's <embed> instead of <img> tag?

When I insert an image in .md file:
[alt](http://mydomain.com/img.jpg)
Then generated HTML will be:
<embed src="http://mydomain.com/img.jpg">
Above is not what I want, and I think,it should be:
<img src="http://mydomain.com/img.jpg">
What can I do?Please help me, thankyou!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.