简体   繁体   English

pdf 由 markdown 和 pandoc 制作,在一段时间后消除双空格

[英]pdf's made from markdown with pandoc eliminate the double space after a period

I have markdown documents that I create pdf's from with a script:我有使用脚本创建 pdf 的降价文档:

#!/usr/bin/env bash
set -euxo pipefail
MARGIN=.35in
pandoc -t html5 -V margin-top=$MARGIN -V margin-left=$MARGIN -V margin-bottom=$MARGIN -V margin-right=$MARGIN -V papersize=letter --css ~/bin/inc/pandoc-pdf.css $1 -o $2 -s --pdf-engine=wkhtmltopdf

It does the job ok... except that sentences are mushed-together by the double spaces being removed.它可以正常工作......除了句子被删除的双空格混合在一起。 It makes sense that's happening because it's generating html and using css to create the pdf.这是有道理的,因为它正在生成 html 并使用 css 创建 pdf。

I can sorta work around that by doing a search/replace %s/ / \\&nsbp;/g and this results in better spacing... except when the line mid-paragraph begins with a new sentence, in which case the &nsbp;我可以通过搜索/替换%s/ / \\&nsbp;/g这个问题,这会导致更好的间距......除非中间段落以新句子开头,在这种情况下&nsbp; character creates an unwanted space at the beginning of the line.字符在行首创建一个不需要的空格。

Does anyone have solution for this?有没有人对此有解决方案? I'd much rather avoid inserting  我宁愿避免插入  characters throughout my documents (and then removing them after pdf generation).整个文档中的字符(然后在生成 pdf 后删除它们)。

I'd even settle for a better markdown-to-pdf process without css, but I've spent several hours on that and this pdf-engine=wkhtmltopdf + css is the best thing I've seen thus far.我什至愿意在没有 css 的情况下使用更好的 markdown-to-pdf 过程,但我已经花了几个小时,这个pdf-engine=wkhtmltopdf + css 是我迄今为止见过的最好的东西。

Given that single-spaces after a sentence is not just a web convention but a print convention too it's highly unlikely that there will be an elegant technical solution for achieving this bad-practice of typography.鉴于句子后的单个空格不仅是一种网络约定,而且也是一种印刷约定,因此极不可能有一种优雅的技术解决方案来实现这种糟糕的排版做法。 So the solution in this case is easy, use proper practice of typography :)所以在这种情况下的解决方案很简单,使用正确的排版练习:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM