问题描述
Wenn 将带有交叉文档链接的 Markdown 文件转换为 html、docs 或 pdf 链接在此过程中被破坏.我使用 pandoc 1.19.1 和 MikTex.这是我的测试用例:
Wenn converting markdown files with cross document links to html, docs or pdf the links get broken in the process.I use pandoc 1.19.1 and MikTex.This is my testcase:
File1: doc1.md
[link1](/doc2.md)
File2: doc2.md
[link2](/doc1.md)
调用 pandoc 的 html 结果:pandoc doc1.md doc2.md -o test.html看起来像这样:
The result in html with this call to pandoc:pandoc doc1.md doc2.md -o test.htmllooks like this:
<p><a href="/doc2.md">link1</a> <a href="/doc1.md">link2</a></p>
作为 pdf,创建了一个链接,但它不起作用.导出为 docx 看起来一样.
As pdf a link is created but it does not work. Exported as docx it looks the same.
我会假设当多个文件被处理并连接到同一个输出文件时,结果应该包含页面内部链接,如 html 输出的锚链接.但是它在输出文件中创建的链接就像在输入文件中一样.甚至原始文件扩展名 .md 也保留在创建的链接中.我做错了什么?
I would have asumed that when multiple files are processed and concatenated into the same output file, then the result should contain page internal links like anchor links for html-output. But instead the link it created in the output file like it was in the input files. Even the original file extension .md is preserved in the created links.What am I doing wrong ?
我的问题有点像这样:解析内部链接的pandoc命令行参数在这个问题的评论中,据说该错误已通过 5 月的拉取请求修复.但是这个bug似乎仍然存在.问候乔治
My problem looks a bit like this:pandoc command line parameters for resolving internal linksIn the comments of this question the bug is said to be fixed by a pull request in May. But the bug still seems to exist.GreetingsGeorg
推荐答案
正如 pandoc README 所述:
As the pandoc README states:
如果给出了多个输入文件,pandoc 将在解析之前将它们全部连接起来(它们之间有空行).
因此对于 pandoc 进行的解析,它会将其视为一个文档...因此您必须在多个文件中构建链接,就好像它们都在一个文件中一样,另请参阅 这个答案 了解详情.
So for the parsing done by pandoc, it sees it as one document... so you'll have to construct your links in multiple files as if it they were all in one file, see also this answer for details.
这篇关于将 Markdown 转换为其他格式时,与 pandoc 的跨文档链接断开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!