Pandoc:转换为 HTML 时没有换行 [英] Pandoc: no line wrapping when converting to HTML

查看:73
本文介绍了Pandoc:转换为 HTML 时没有换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 Markdown 转换为 HTML,如下所示:

I am converting from Markdown to HTML like so:

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

一切正常,除了文本没有被换行.我尝试了不同的列长度,没有效果.删除了选项,不行.无论我尝试过什么,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?

我使用的是 pandoc 版本 1.12.4.2.

I'm using pandoc version 1.12.4.2.

预先感谢您的帮助!

推荐答案

Pandoc 在 HTML 中放置换行符,因此源代码更易于阅读.默认情况下,它不会插入
-tags.

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

如果您想保留 Markdown 输入中的换行符:

If you want to preserve line breaks from markdown input:

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

但是,通常在浏览器中打开 HTML 文件时限制文本宽度的更好方法是调整 HTML 模板 (pandoc -D html5) 并添加一些 CSS,例如:

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>
...

这篇关于Pandoc:转换为 HTML 时没有换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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