Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[新功能]注脚以非数字形式展示 #2

Closed
CoreJa opened this issue Apr 13, 2019 · 2 comments
Closed

[新功能]注脚以非数字形式展示 #2

CoreJa opened this issue Apr 13, 2019 · 2 comments

Comments

@CoreJa
Copy link

CoreJa commented Apr 13, 2019

注脚在markdown下可以以各种自己起的名字作为注脚的标记,但他们在渲染后总以1到n的数字形式展现,例如:

你好[^hello含义]
[^hello含义]: 一种对人的问候方式

此时你好的注脚上标是数字[1],但有些情况下我们会希望这个注脚就是我们给出的标记[hello含义]而不是数字[1]

是否可以提供一个参数来作为开关呢?
例如在front matter里加入footnote-order: true时,所有注脚将会按照数字顺序排列,而值为false时,注脚将会使用在md文档里本身写的注脚标记[hello含义]

感谢作者开发,如果有时间的话我会自己看看代码,我会尝试提交个pr——如果能实现的话

El Psy Congroo.

@Ritsuka314
Copy link
Owner

你好。

十分抱歉刚才由于失误关闭了此 issue。
现已重新打开。

另先前的 comment 有严重错误,若您通过邮件收到了它,请忽视。

首先您也许已经知道 Pandoc 的工作原理:

  1. 输入根据格式被相应的 Reader 解析至 Pandoc 内部统一通用的树状结构。

  2. 用户指定的 filters 被依序使用在该结构上。

  3. 该结构随后被指定的输出格式相应的 Writer 渲染。

其中 Reader 和 Writer 之间不直接沟通。

因此所提出的 issue 涉及到两方面。

  1. "在渲染后总以1到n的数字形式展现" 是 Pandoc 的 HTML Writer 的特性,并非本插件所做的决定。

  2. 在解析的过程中,完成您提出功能所需的数据就已经丢失了。

    考虑如下 MD 片段

    Footnote 1 link[^first].
    
    [^first]: Footnote **can have markup**
    
        and multiple paragraphs.

    该片段会被 Pandoc 解析为如下语法树(以 JSON 交换格式书写)

    {"t":"Para","c": [
        {"t":"Str","c":"Footnote"},
        {"t":"Space"},
        {"t":"Str","c":"1"},
        {"t":"Space"},
        {"t":"Str","c":"link"},
        {"t":"Note","c":[
            {"t":"Para","c":[
                {"t":"Str","c":"Footnote"},
                {"t":"Space"},
                {"t":"Strong","c":[
                    {"t":"Str","c":"can"},
                    {"t":"Space"},
                    {"t":"Str","c":"have"},
                    {"t":"Space"},
                    {"t":"Str","c":"markup"}]}]},
            {"t":"Para","c":[
                {"t":"Str","c":"and"},
                {"t":"Space"},
                {"t":"Str","c":"multiple"},
                {"t":"Space"},
                {"t":"Str","c":"paragraphs."}]}]}

    如你所见,脚注中原有的 first 标号在此已不可见,且各脚注的内容已被嵌入到所有引用该脚注的位置。

    故目前我认为该功能原则上不可实现。

@CoreJa
Copy link
Author

CoreJa commented Apr 14, 2019

似乎的确如此。如果要完成相应功能就得找upstream提新feature了emmmm。
先道谢啦。那这issue就关掉了。

如果pandoc有与此相关的新的消息再reopen

@CoreJa CoreJa closed this as completed Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants