Pandoc: no line wrapping when converting to HTML

时间秒杀一切 提交于 2019-12-12 20:18:29

问题


I am converting from Markdown to HTML like so:

pandoc --columns=70 --mathjax -f markdown input.pdc -t html -Ss > out.html

Everything works fine, except for the fact that the text doesn't get wrapped. I tried different columns lengths, no effect. Removed options, no go. Whatever I tried, the HTML just doesn't get wrapped. I search the bug tracker, but there don't seem to be any open bugs relating to this issue. I also checked the documentation, but as far as I could glean, the text ought be line-wrapped... So, have I stumbled into a bug?

I'm using pandoc version 1.12.4.2.

Thanks in advance for your help!


回答1:


Pandoc puts newlines in the HTML so the source code is easier to read. By default, it doesn't insert <br>-tags.

If you want to preserve line breaks from markdown input:

pandoc -f markdown+hard_line_breaks input.md output.html

However, usually a better approach to limit the text width when opening the HTML file in the browser is to adapt the HTML template (pandoc -D html5) and add some CSS, like:

<!DOCTYPE html>
<html$if(lang)$ lang="$lang$"$endif$>
<head>
  <style>
  body {
     width: 46em;
  }
  </style>
...



回答2:


It is not clear what text should get wrapped but does not as you did not provide a sample.

Pandoc supports several line breaking scenarios in markdown documents.

What you may be looking for is the hard_line_breaks extension

If it is so then your command should look like

pandoc --columns=70 --mathjax -f markdown+hard_line_breaks input.pdc -t html -Ss > out.html

I'd recommend you to read about all the markdown-relevant options and configure pandoc to match your input markdown flavor



来源:https://stackoverflow.com/questions/24469694/pandoc-no-line-wrapping-when-converting-to-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!