class Lexbor::Parser

Defined in:

lexbor/parser.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(ec : EncodingConverter, page : String) #

[View source]
def self.new(ec : EncodingConverter, io : IO) #

[View source]
def self.new(page : String) #

[View source]
def self.new(slice : Slice) #

[View source]
def self.new(io : IO) #

[View source]

Instance Method Detail

def body #

[View source]
def body! #

[View source]
def create_node(tag_id : Lexbor::Lib::TagIdT) #

Create a new node

Note: this does not add the node to any document or tree. It only creates the object that can then be appended or inserted. See Node#append_child, Node#insert_after, and Node#insert_before

doc = Lexbor::Parser.new ""
div = doc.create_node(:div)
a = doc.create_node(:a)

div.to_html # <div></div>
a.to_html   # <a></a>

[View source]
def create_node(tag_sym : Symbol) #

[View source]
def create_node(tag_name : String) #

[View source]
def create_text_node(text : String) #

[View source]
def css(*args, **options) #

Css selectors, see Node#css


[View source]
def css(*args, **options, &) #

Css selectors, see Node#css


[View source]
def document #

[View source]
def document! #

[View source]
def finalize #

[View source]
def free #

[View source]
def head #

[View source]
def head! #

[View source]
def html #

[View source]
def html! #

[View source]
def nodes(tag_id : Lexbor::Lib::TagIdT) #

Top level node filter (select all nodes in tree with tag_id) returns Lexbor::Iterator::Collection equal with lexbor.root!.scope.nodes(...)

lexbor.nodes(Lexbor::Lib::TagIdT::LXB_TAG_DIV).each { |node| ... }


[View source]
def nodes(tag_sym : Symbol) #

Top level node filter (select all nodes in tree with tag_sym) returns Lexbor::Iterator::Collection equal with lexbor.root!.scope.nodes(...)

lexbor.nodes(:div).each { |node| ... }


[View source]
def nodes(tag_str : String) #

Top level node filter (select all nodes in tree with tag_sym) returns Lexbor::Iterator::Collection equal with lexbor.root!.scope.nodes(...)

lexbor.nodes("div").each { |node| ... }


[View source]
def root #

[View source]
def root! #

[View source]
def to_html(*args, **options) #

Convert html tree to html string, see Node#to_html


[View source]
def to_html(*args, **options, &) #

Convert html tree to html string, see Node#to_html


[View source]
def to_pretty_html(*args, **options) #

[View source]
def to_pretty_html(*args, **options, &) #

[View source]