Pandoc Markdown 到纯文本格式

lig*_*iri 4 markdown pandoc

我的机器上最新安装的 Pandoc(pandoc 1.13.2.1)版本似乎有问题。使用之前安装的版本,从 Markdown 到纯文本的转换将生成'Setext-style headers---'=' for H1 and '-' for H2---纯文本输出。此外,我还注意到两个不确定的问题:

  • Pandoc 现在会自动为标题生成大写字母
  • Pandoc 现在在标题之前添加了两个新行 (\n)

在过去的几分钟里,我一直在玩不同的 pandoc 选项,但运气不佳。

如何将插图 #1转换为插图 #3

环境 pandoc (pandoc 1.13.2.1) Kubuntu 15.10

插图 #1:输入 Markdown 文件

# Title

## Section
* This is the section.

### Subsection
* This happens to be the subsection
Run Code Online (Sandbox Code Playgroud)

插图#2:运行后输出纯文本 pandoc -f markdown -t plain pandoc_markdown_issue.md

TITLE


Section

-   This is the section.

Subsection

-   This happens to be the subsection
Run Code Online (Sandbox Code Playgroud)

插图 #3:所需的输出

Title
=====

Section
-------
-   This is the section.

Subsection
----------
-   This happens to be the subsection
Run Code Online (Sandbox Code Playgroud)

小智 9

我可以通过完全省略-f-t标志并让 Pandoc 从输出文件扩展名推断转换格式来实现您想要的输出:

pandoc file.md -o file.txt
Run Code Online (Sandbox Code Playgroud)

或者,使用-t plain似乎也有效:

pandoc -f markdown -t plain file.md -o file.txt
Run Code Online (Sandbox Code Playgroud)

不太确定为什么第一个例子有效。我的猜测是它是 Markdown 阅读器之一,因为有多个。


Joh*_*ane 6

纯文本编写器已更改为使用古腾堡计划纯文本书籍的通用格式。当然,没有选择会让所有人满意。对于您提供的示例,使用 Markdown writer 效果会很好。