简体   繁体   English

在Haddock文档中使用unicode字符

[英]Use of unicode characters in Haddock documentation

Haddock seems to incorrectly re-encode non-ASCII characters in the documentation in UTF-8 encoded source files. Haddock似乎错误地重新编码UTF-8编码源文件的文档中的非ASCII字符。 I often need to include mathematical formulas in the documentation and they are much more readable if some common math symbols such as summation (∑) can be used. 我经常需要在文档中包含数学公式,如果可以使用诸如求和(Σ)之类的常见数学符号,它们更易读。

However, after running the files through haddock, these symbols become blank squares. 但是,在通过haddock运行文件后,这些符号变为空白方块。 Haddock has the option --use-unicode but that just converts function arrows in function signatures etc. into unicode characters, while still breaking the actually documentation. Haddock有选项--use-unicode但它只是将函数签名等中的函数箭头转换为unicode字符,同时仍然打破了实际的文档。

Even better would be if this can be controlled from cabal haddock ! 更好的是,如果这可以从cabal haddock控制!

I'm using Haddock version 2.9.4. 我正在使用Haddock版本2.9.4。

Note that Haddock uses the GHC API to do parsing. 请注意,Haddock使用GHC API进行解析。 Non-ASCII characters in comments are not handled properly by GHC < 7.4, but it seems that with GHC 7.4 it works fine. GHC <7.4不能正确处理注释中的非ASCII字符,但似乎使用GHC 7.4它可以正常工作。

If UTF-8 cannot be used and numeric character references like &#8721; 如果不能使用UTF-8,则数字字符引用如&#8721; or &#x2211; 或者&#x2211; (these are correct references for the n-ary summation symbol ∑) are regarded as unreadable, then I'm afraid the only option is to use named references like &sum; (这些是n元求和符号Σ的正确引用)被认为是不可读的,那么我担心唯一的选择是使用像&sum;这样的命名引用&sum; , if they get passed thru to the HTML result and are supported by the browser(s) that will be used. ,如果它们通过HTML结果并且将被将要使用的浏览器支持。

That's a big “if,” since the new HTML5 entities have rather limited support, but perhaps in an intranet where everyone uses Firefox... HTML5 entities: http://www.whatwg.org/specs/web-apps/current-work/multipage/named-character-references.html 这是一个很大的“如果”,因为新的HTML5实体支持相当有限,但可能在内部网中,每个人都使用Firefox ...... HTML5实体: http//www.whatwg.org/specs/web-apps/current-工作/多页/命名字符references.html

(And most of the references are not as mnemonic as &sum; .) (并且大多数参考文献并不像&sum;那样助记&sum; 。)

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

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