HTML
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
def self.escape(string : String, io : IO)Source
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"
def self.escape(string : String) : StringSource
Encodes a string with HTML entity substitutions.
require "html" HTML.escape("Crystal & You") # => "Crystal & You"
def self.unescape(string : String)Source
Decodes a string that contains HTML entities.
HTML.unescape("Crystal & You") # => "Crystal & You"
© 2012–2017 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.22.0/HTML.html