将Markdown转换为docx并保留换行符,使用Pandoc。

huangapple go评论52阅读模式
英文:

Convert from markdown to docx and keeping line break using Pandoc

问题

I want to convert a markdown file to docx and keeping the linebreak using pandoc.
the markdown look like this:

I'm a test about line break
in a docx document

And when using pandoc with the argument to preserve the wrapping I get:

I’m a test about line break in a docx document

So far I tried:

pandoc test.md --wrap=preserve -o test.docx
pandoc test.md --wrap=none -o test.docx
pandoc test.md -o test.docx

None worked.

I'm using pandoc 3.1.1 on OSX 12.3

英文:

I want to convert a markdown file to docx and keeping the linebreak using pandoc.
the markdown look like this:

I'm a test about line break
in a docx document

And when using pandoc with the argument to preserve the wrapping I get:

I’m a test about line break in a docx document

So far I tried :

pandoc test.md --wrap=preserve -o test.docx
pandoc test.md --wrap=none -o test.docx
pandoc test.md -o test.docx

None worked.

I'm using pandoc 3.1.1 on OSX 12.3

答案1

得分: 1

--wrap选项仅影响输出文件中文本的书写方式,但不影响换行符的语义意义。为此,我们需要使用另一个扩展:hard_line_breaks

> 扩展:hard_line_breaks
>
> 导致段落内的所有换行符被解释为硬换行符,而不是空格。

使用时需搭配 --from=markdown+hard_line_breaks

英文:

The --wrap option only affects the way the text is written in the output file, but does not affect the semantic meaning of a line break. For that we need a different extension: hard_line_breaks:

> Extension: hard_line_breaks
>
> Causes all newlines within a paragraph to be interpreted as hard line breaks instead of spaces.

Use with --from=markdown+hard_line_breaks.

huangapple
  • 本文由 发表于 2023年4月1日 00:09:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75900641.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定