简体   繁体   English

使用Pandoc从HTML转换为Markdown时如何保留标识符

[英]How do I preserve identifiers while converting from HTML to Markdown with Pandoc

I can't find the right parameter for this. 我找不到正确的参数。

In my HTML-document I have a line like this: 在我的HTML文档中,有这样一行:

<h2 id="seminar-teil-1">Seminar Teil 1</h2>

Now I want to convert this .html-document to a Markdown-Document. 现在,我想将此.html文档转换为Markdown文档。 The end result should be: 最终结果应为:

## Seminar Teil 1   {#seminar-teil-1}

How do I get this done? 我该如何完成?

Ah! 啊! No wonder you were struggling. 难怪你在挣扎。 By default, identifiers are in fact preserved. 默认情况下,标识符实际上是保留的。

> pandoc -f html -t markdown
<h1 id="uid">Seminar 1</h1>

Output 产量

Seminar 1 {#uid}
=========

There is one special case though, when your identified matches the identifier which pandoc automatically generates then no identifier is emitted. 但是有一种特殊情况,当您识别出的与pandoc自动生成的标识符匹配时,则不会发出任何标识符。 The automatic identifier is basically a lower case alphanumeric version of the title interspersed with dashs (exactly like your custom identifier!). 自动标识符基本上是标题的小写字母数字版本,中间带有破折号(完全类似于您的自定义标识符!)。

To turn this feature off run pandoc as follows 要关闭此功能,请按以下方式运行pandoc

> pandoc -f html -t markdown-auto_identifiers
<h2 id="seminar-teil-1">Seminar Teil 1</h2>
Seminar Teil 1 {#seminar-teil-1}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pandoc:从 Markdown 转换为 HTML 时将字体系列更改为 sans - Pandoc: Change font family to sans while converting from Markdown to HTML pandoc:从markdown转换时添加onload等html事件 - pandoc: add html events such as onload when converting from markdown 使用Pandoc将HTML中的多行代码段转换为Markdown - Converting multiline code snippets in HTML to Markdown with pandoc 如何链接到同一目录中的文档部分(pandoc markdown-&gt; html输出) - How do I make a link to a section of a document in the same directory(pandoc markdown->html output) 从 markdown 转换为 HTML 时,使用 Pandoc Lua 过滤器替换 HTML 标签 - Replace HTML tags using Pandoc Lua filter when converting from markdown to HTML 使用 Pandoc 从 HTML 转换为 Markdown 时为代码块添加正确的语法名称 - Add proper syntax name to code blocks when converting from HTML to Markdown with Pandoc Pandoc在转换为Markdown时会丢弃“未知” HTML元素 - Pandoc drops “unknown” HTML elements when converting to markdown 为什么pandoc在将html转换为markdown时会保留span和div标签? - Why pandoc keeps span and div tags when converting html to markdown? HTML/JS - 从 Markdown 转换时无法呈现 HTML - HTML/JS - Unable to Render HTML while Converting from Markdown 我们如何让 pandoc 从 markdown 生成漂亮的、人类可读的 HTML? - How can we make pandoc produce pretty, human readable HTML from markdown?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM