html.entities: adding better HTML 5 escaping.

db4
John Benediktsson 2014-04-21 19:03:59 -07:00
parent 70fd2ebf52
commit e79bb8f6e4
4 changed files with 2368 additions and 0 deletions

View File

@ -0,0 +1 @@
John Benediktsson

View File

@ -0,0 +1,10 @@
USING: help.markup help.syntax strings ;
IN: html.entities
HELP: html-escape
{ $values { "str" string } { "newstr" string } }
{ $description "Replaces special characters " { $snippet "&" } ", " { $snippet "<" } ", " { $snippet ">" } ", " { $snippet "\"" } ", and " { $snippet "'" } " to HTML-safe sequences." } ;
HELP: html-unescape
{ $values { "str" string } { "newstr" string } }
{ $description "Convert all named and numeric character references (e.g. &gt;, &#62;, &x3e;) in the string " { $snippet "str" } " to the corresponding unicode characters using the rules defined by the HTML5 standard" } ;

View File

@ -0,0 +1,9 @@
USING: tools.test ;
IN: html.entities
{ "&" } [ "&amp;" html-unescape ] unit-test
{ "a" } [ "&#x61" html-unescape ] unit-test
{ "<foo>" } [ "&lt;foo&gt;" html-unescape ] unit-test
{ "&amp;" } [ "&" html-escape ] unit-test
{ "&lt;foo&gt;" } [ "<foo>" html-escape ] unit-test

File diff suppressed because it is too large Load Diff