使用 github_document 将 .rmd 转换为 .md 时,两个 space 换行符在 GitHub 上不起作用

Two space line break doesnt work on GitHub when converting .rmd to .md using github_document

我试图在我的 YAML header.[=24= 中使用 output: github_document.rmd 文档转换为 .md 以上传到 GitHub ]

显然,转换不考虑我在 .rmd 文件中用于强制换行的两个或更多空格。

示例: 我创建了这个 .rmd 小文件:

---
title: "Line Break issue"
output: github_document
---

1.  My First point  
Another point right below  
and more

1.  My second point

我在"My first Point"和"Another point..."和"and more"之间用了两个空格强制换行。当我编织时,预览很好,但是,当我上传到 GitHub 时,换行符仅在 .rmd 文件中得到充分尊重,如您所见 here but apparently gone in the .md file as you can here.

这是为什么?

编辑:

我在 R 3.3.0 上的 RStudio Version 0.99.1130 中使用 rmarkdown_0.9.6

在我看来,GitHub 的降价渲染器的行为似乎发生了变化。以前 GitHub Flavored Markdown 会自动为 Markdown 中的任何换行符创建一个 HTML 换行符(即使那些没有 2 个尾随空格的换行符)。结果,pandoc 转换为 github_markdown 去掉了 2 个尾随空格(因为它们在 github_markdown 中没有必要或没有意义)。

今天在 GitHub 上发布了一些测试文件,但看起来他们现在 需要 两个空格来产生换行符。我不知道这个更改是永久的还是临时的(因为它肯定会破坏一堆现有代码)。为了解决这个问题,我在 github_document:

中添加了一个 hard_line_breaks 选项

https://github.com/rstudio/rmarkdown/commit/0cbfcf7ebde5f587e70a064ae7c484cfd849ba6a

通过此更改,您的示例的 YAML 需要看起来像这样才能保留两个空格:

---
title: "Line Break issue"
output: 
  github_document:
    hard_line_breaks: false
---

如果这似乎是 GitHub 的永久更改,那么我会将默认设置更改为 true,这样 github_document 将默认生成正确的降价。