class HTML5::Token

Overview

A Token consists of a TokenType and some data (tag name for start and end tags, content for text, comments and doctypes). A tag Token may also contain an array of Attributes. data is unescaped for all Tokens (it looks like "a<b" rather than "a<b"). For tag Tokens, data_atom is the atom for data, or zero if data is not a known tag name.

Defined in:

html5/token.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(type : HTML5::TokenType = TokenType::Error, data_atom : HTML5::Atom::Atom = Atom::Atom.zero, data : String = "", attr : Array(HTML5::Attribute) = Array(Attribute).new(0)) #

[View source]

Instance Method Detail

def attr : Array(Attribute) #

[View source]
def attr=(attr : Array(Attribute)) #

[View source]
def data : String #

[View source]
def data=(data : String) #

[View source]
def data_atom : Atom::Atom #

[View source]
def data_atom=(data_atom : Atom::Atom) #

[View source]
def tag_string #

returns a string representation of a tag Token's data and attr


[View source]
def to_s(io : IO) : Nil #
Description copied from class Reference

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>

[View source]
def to_s #
Description copied from class Object

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.


[View source]
def type : TokenType #

[View source]
def type=(type : TokenType) #

[View source]