我有一个标记为utf-8编码的Markdown文本文件,它有一些非ASCII字符,例如’
。我无法获得参考Perl实现来正确处理这些字符,但我可以使用Pandoc。我希望能够使用Markdown mode中的C-c C-c p
直接从Emacs呈现我的Markdown文件,但这仍然不适合我。我得到的东西看起来像一个空格而不是非ASCII字符。例如,
I love apostrophe’s.
变成
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>I love apostrophe s.</p>
</body>
</html>
请注意,HTML包含charset=utf-8
。它与我从命令行运行Pandoc几乎完全相同,除了缺少的撇号。我使用pandoc -f markdown -t html -s --mathjax --highlight-style pygments
从here调用Pandoc,无论是来自Emacs还是命令提示符。
我可以从Emacs中正确呈现撇号和其他unicode字符吗?
编辑:使用@ db48x建议的C-u C-x =
命令,我确认空白字符是常规空格(#x20)
答案 0 :(得分:2)
我对德语变音字符有同样的问题并想出了一个解决方案:如果我添加行
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
到markdown文件的开头,它最终会出现在html文件中,虽然嵌入在<p></p>
标签中,但仍有效。 C-c C-c e
也很好地导出了我的变形金刚和你的撇号。
答案 1 :(得分:2)
为避免在所有降价文件的标题中输入<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
(这不是直截了当的),您可以告诉emacs的降价模式在编译时为您执行此操作。您只需自定义Markdown Xhtml Header Content
变量并将其设置为<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
。
您需要运行M-x customize-mode
,查找Markdown Xhtml Header Content
并使用新值保存。
答案 2 :(得分:1)
正在运行M-x customize-variable
并切换markdown-command-needs-filename
以解决问题。