<p>I'm writing a simple static blog generator with support for markdown footnotes; however, blackfriday is using relative footnotes (simply <code>#fn:<label></code>, which means all footnote marker links that appear in the post snippets on the index page expect to have corresponding footnotes on the index page, when they should ideally link to the footnote location on the individual post's page (e.g., if there is a post called "foo" with a footnote marker <code>a</code> in its snippet, then clicking on the footnote marker should take me to <code>foo.html#fn:a</code> and not <code>index.html#fn:a</code>). Has anyone else encountered this problem? What solutions exist?</p>
<hr/>**评论:**<br/><br/>ChristophBerger: <pre><p>An easy solution could be to have your blog generator remove all footnotes from the summary snippets. No footnote, no wrong link. (I don't believe the readers would miss the footnotes on the index page.)</p></pre>weberc2: <pre><p>This isn't a bad idea, although making another pass through the snippet text sounds expensive, and faster alternatives become relatively complex. I was hoping for the ability to customize the footnote link via blackfriday. If such a thing doesn't already exist, I might submit a feature request.</p></pre>Bake_Jailey: <pre><p>Don't optimize prematurely. Give it a go, and if it's really a problem, then you can benchmark, and fix it later. You might find that it's really not that big of a deal. My guess is that it won't be (given caching). Either way, something is better than nothing.</p></pre>weberc2: <pre><blockquote>
<p>Don't optimize prematurely.</p>
</blockquote>
<p>This isn't premature optimization; two passes are always going to be slower than a single pass, and I don't see how any kind of caching can save us from this reality. :(</p>
<blockquote>
<p>Either way, something is better than nothing.</p>
</blockquote>
<p>Agreed. I did some more research last night and discovered that a <a href="https://github.com/russross/blackfriday/issues/269" rel="nofollow">2-line change</a> to blackfriday solves the problem, so I'm hoping <a href="/u/russross" rel="nofollow">/u/russross</a> is okay with the solution. :)</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传