HTML

module HTML

Overview

Handles encoding and decoding of HTML entities.

Defined in:

html.cr

Constant Summary

SUBSTITUTIONS = {'!' => "!", '"' => """, '$' => "$", '%' => "%", '&' => "&", '\'' => "'", '(' => "(", ')' => ")", '=' => "=", '>' => ">", ' => "<", '+' => "+", '@' => "@", '[' => "[", ']' => "]", '`' => "`", '{' => "{", '}' => "}", ' ' => " "}

Class Method Summary

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

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部