File: htree.rb

package info (click to toggle)
ruby-htree 0.8+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 448 kB
  • ctags: 703
  • sloc: ruby: 5,931; makefile: 24
file content (97 lines) | stat: -rw-r--r-- 2,698 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#
# = htree.rb
#
# HTML/XML document tree
#
# Author:: Tanaka Akira <akr@fsij.org>
#
# == Features
#
# - Permissive unified HTML/XML parser
# - byte-to-byte round-tripping unparser
# - XML namespace support
# - Dedicated class for escaped string.  This ease sanitization.
# - XHTML/XML generator
# - template engine: link:files/htree/template_rb.html
# - recursive template expansion
# - REXML tree generator: link:files/htree/rexml_rb.html
#
# == Example
#
# The following one-liner prints parsed tree object.
#
#   % ruby -rhtree -e 'pp HTree(ARGF)' html-file
#
# The following two-line script convert HTML to XHTML.
#
#   require 'htree'
#   HTree(STDIN).display_xml
#
# The conversion method to REXML is provided as to_rexml.
#
#     HTree(...).to_rexml
#
# == Module/Class Hierarchy
#
# * HTree
#   * HTree::Name
#   * HTree::Context
#   * HTree::Location
#   * HTree::Node
#     * HTree::Doc
#     * HTree::Elem
#     * HTree::Text
#     * HTree::XMLDecl
#     * HTree::DocType
#     * HTree::ProcIns
#     * HTree::Comment
#     * HTree::BogusETag
# * HTree::Error
#
# == Method Summary
#
# HTree provides following methods.
#
# - Parsing Methods
#   - HTree(<i>html_string</i>) -> HTree::Doc
#   - HTree.parse(<i>input</i>) -> HTree::Doc
#
# - Generation Methods
#   - HTree::Node#display_xml -> STDOUT
#   - HTree::Node#display_xml(<i>out</i>) -> <i>out</i>
#   - HTree::Node#display_xml(<i>out</i>, <i>encoding</i>) -> <i>out</i>
#   - HTree::Text#to_s -> String
#
# - Template Methods
#   - HTree.expand_template{<i>template_string</i>} -> STDOUT
#   - HTree.expand_template(<i>out</i>){<i>template_string</i>} -> <i>out</i>
#   - HTree.expand_template(<i>out</i>, <i>encoding</i>){<i>template_string</i>} -> <i>out</i>
#   - HTree.compile_template(<i>template_string</i>) -> Module
#   - HTree{<i>template_string</i>} -> HTree::Doc
#
# - Traverse Methods
#   - HTree::Elem#attributes -> Hash[HTree::Name -> HTree::Text]
#   - HTree::Elem::Location#attributes -> Hash[HTree::Name -> HTree::Location]
#
# - Predicate Methods
#   - HTree::Traverse#doc? -> true or false
#   - HTree::Traverse#elem? -> true or false
#   - HTree::Traverse#text? -> true or false
#   - HTree::Traverse#xmldecl? -> true or false
#   - HTree::Traverse#doctype? -> true or false
#   - HTree::Traverse#procins? -> true or false
#   - HTree::Traverse#comment? -> true or false
#   - HTree::Traverse#bogusetag? -> true or false
#
# - REXML Tree Generator
#   - HTree::Node#to_rexml -> REXML::Child

require 'htree/parse'
require 'htree/extract_text'
require 'htree/equality'
require 'htree/inspect'
require 'htree/display'
require 'htree/loc'
require 'htree/traverse'
require 'htree/template'
require 'htree/rexml'