module HTML
Overview
Handles encoding and decoding of HTML entities.
Defined in:
html.crConstant Summary
-
SUBSTITUTIONS =
{'!' => "!", '"' => """, '$' => "$", '%' => "%", '&' => "&", '\'' => "'", '(' => "(", ')' => ")", '=' => "=", '>' => ">", '<' => "<", '+' => "+", '@' => "@", '[' => "[", ']' => "]", '`' => "`", '{' => "{", '}' => "}", ' ' => " "}
Class Method Summary
-
.escape(string : String, io : IO)
Encodes a string to HTML, but writes to the
IO
instance provided. -
.escape(string : String) : String
Encodes a string with HTML entity substitutions.
-
.unescape(string : String)
Decodes a string that contains HTML entities.
Class Method Detail
Encodes a string to HTML, but writes to the IO
instance provided.
io = IO::Memory.new
HTML.escape("Crystal & You", io) # => nil
io.to_s # => "Crystal & You"
Encodes a string with HTML entity substitutions.
require "html"
HTML.escape("Crystal & You") # => "Crystal & You"
Decodes a string that contains HTML entities.
HTML.unescape("Crystal & You") # => "Crystal & You"