1
我已经将一堆markdown格式的注释备份到XML文档中。这当然意味着我需要HTMLescape他们。当我尝试使用CGI.unescapeHTML时,它会在标记中添加一些奇怪的字符,而这些字符在所有浏览器中都不能很好地呈现。红宝石CGI.unescapeHTML生成奇怪的字符
具体而言,它用“\ 302 \ 240”替换两个空格,但不一致。我如何才能阻止这种行为?
如:
s = "I am seeing more and more <a href="http://github.com/aslakhellesoy/cucumber /tree/master">Cucumber</a> usage. This is a good thing! But I'm also seeing people who are not using regular expressions to their fullest. Here are some quick regex tips to keep you features readable:

* `(?:a|an)` -- using a this construct you can group things wihout actually matching them. I'm seeing a lot of steps that have unused params because someone needed a group but didn't know how to avoid capturing it
"
CGI.unescapeHTML s
# => "I am seeing more and more <a href=\"http://github.com/aslakhellesoy/cucumber/tree/master\">Cucumber</a> usage.\302\240 This is a good thing!\302\240 But I'm..."
你使用的是什么版本?我没有在1.8.7上看到它。 – 2009-09-02 21:01:46
我发现这是由Haml将 个字符作为空格引起的。它在这里工作,因为SO格式化解决了问题。尽管如此,还是有几个小时的工作要做。 – 2009-09-03 18:55:03