使用 pandoc 保留标题中的换行符 [英] Preserve line breaks in title using pandoc

查看:18
本文介绍了使用 pandoc 保留标题中的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑一下 pandoc 风格的 Markdown 中的以下标题栏:

% Higgelty Pigglety Pop!或者生活必须有更多%莫里斯·森达克

在这里,换行符是标题的一部分.可以重新格式化标题以将其插入常规文本流中,例如Higgelty Pigglety Pop!或者,生活中必须有更多",但是当不被提及但在文档的标题页上使用时,保留换行符至关重要.根据样式,它可能如下所示:

<上一页>Higgelty Pigglety 流行音乐!或者生活必须不止于此莫里斯·森达克

我的问题:如何在 pandoc 的输出中实现正确的多行标题显示?

便携式版本是首选,但我也满足于仅使用 LaTeX 的 hack.

解决方案

% Higgelty Pigglety Pop!或者 生活必须有更多%莫里斯·森达克

Pandoc Markdown 默认启用 escaped_line_breaks 扩展:

<块引用>

反斜杠后跟换行符也是硬换行符.注意:在多行和网格表格单元格中,这是创建硬换行符的唯一方法,因为单元格中的尾随空格会被忽略.

Consider the following title block in pandoc-flavored Markdown:

% Higgelty Pigglety Pop!
  or
  There Must Be More to Life
% Maurice Sendak

Here, line breaks are part of the title. It is possible to reformat the title in order to insert it into regular text flow, e.g. "Higgelty Pigglety Pop! Or, There Must Be More to Life", but when not talked about but used on the title page of a document, preserving the line breaks is crucial. Depending on the style, it might look like this:

          Higgelty Pigglety Pop!
                   or
        There Must Be More to Life
             Maurice Sendak

My question: How can I achieve a proper multi-line title display in the output of pandoc?

A portable version would be preferred, but I'd also be content with a LaTeX-only hack.

解决方案

% Higgelty Pigglety Pop! 
  or 
  There Must Be More to Life
% Maurice Sendak

Pandoc Markdown enables the escaped_line_breaks extension by default:

A backslash followed by a newline is also a hard line break. Note: in multiline and grid table cells, this is the only way to create a hard line break, since trailing spaces in the cells are ignored.

这篇关于使用 pandoc 保留标题中的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆