2009-09-02 4 views
1

마크 업 형식의 주석을 XML 문서에 백업했습니다. 이것은 물론 내가 HTMLescape해야한다는 것을 의미했다. CGI.unescapeHTML을 사용하려고하면 모든 브라우저에서 잘 렌더링되지 않는 마크 업에 이상한 문자가 추가됩니다.이상한 문자를 생성하는 Ruby 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&#x000A" 
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..." 
+0

어떤 버전을 사용하고 있습니까? 나는 1.8.7에서 그것을 보지 않을 것이다. –

+0

이것은 Haml이   문자를 공백으로 추가하여 발생하는 것으로 나타났습니다. 그것은 SO 포맷팅이 문제를 제거했기 때문에 여기서 작동합니다. 그러나 이것을 발견하는 데는 두어 시간의 노력이 필요했습니다. –

답변

0

사람들은 줄 바꿈하지 않는 공백이 있습니다. Read up on wikipedia.

In computer-based text processing and digital typesetting, a 
non-breaking space, also known as a no-break space or 
non-breakable space (NBSP), is a variant of the space character 
that prevents an automatic line break (line wrap) at its position. 
In certain formats (such as HTML), it also prevents the 
“collapsing” of multiple consecutive whitespace characters into a 
single space. The non-breaking space is also known as a hard space 
or fixed space. In Unicode, it is encoded as U+00A0 no-break space 
(HTML: &#160; &nbsp;). 
관련 문제