@@ -10,7 +10,23 @@ __precompile__()
10
10
module HTML_Entities
11
11
using StrTables
12
12
13
- include (" html_table.jl" )
13
+ VER = UInt32 (1 )
14
+
15
+ immutable HTML_Table{T} <: AbstractEntityTable
16
+ ver:: UInt32
17
+ tim:: String
18
+ inf:: String
19
+ base32:: UInt32
20
+ base2c:: UInt32
21
+ nam:: StrTable{T}
22
+ ind:: Vector{UInt16}
23
+ val16:: Vector{UInt16}
24
+ ind16:: Vector{UInt16}
25
+ val32:: Vector{UInt16}
26
+ ind32:: Vector{UInt16}
27
+ val2c:: Vector{UInt32}
28
+ ind2c:: Vector{UInt16}
29
+ end
14
30
15
31
function __init__ ()
16
32
const global _tab =
@@ -34,20 +50,16 @@ function _get_strings{T}(val::T, tab::Vector{T}, ind::Vector{UInt16})
34
50
_tab. nam[ind[rng]]
35
51
end
36
52
37
- """ Given a HTML name, return the string it represents, or an empty string if not found"""
38
53
function lookupname (str:: AbstractString )
39
54
rng = searchsorted (_tab. nam, str)
40
55
isempty (rng) ? _empty_str : _get_str (_tab. ind[rng. start])
41
56
end
42
57
43
- """ Given a character, return all exact matches to the character as a vector"""
44
58
matchchar (ch:: Char ) =
45
59
(ch <= ' \u ffff'
46
60
? _get_strings (ch% UInt16, _tab. val16, _tab. ind16)
47
61
: (ch <= ' \U 1ffff' ? _get_strings (ch% UInt16, _tab. val32, _tab. ind32) : _empty_str_vec))
48
62
49
- """ Given a string, return all exact matches to the string as a vector"""
50
- function matches end
51
63
matches (str:: AbstractString ) = matches (convert (Vector{Char}, str))
52
64
function matches (vec:: Vector{Char} )
53
65
if length (vec) == 1
@@ -59,8 +71,6 @@ function matches(vec::Vector{Char})
59
71
end
60
72
end
61
73
62
- """ Given a string, return all of the longest matches to the beginning of the string as a vector"""
63
- function longestmatches end
64
74
longestmatches (str:: AbstractString ) = longestmatches (convert (Vector{Char}, str))
65
75
function longestmatches (vec:: Vector{Char} )
66
76
isempty (vec) && return _empty_str_vec
@@ -72,9 +82,6 @@ function longestmatches(vec::Vector{Char})
72
82
matchchar (vec[1 ])
73
83
end
74
84
75
-
76
- """ Given a string, return all of the HTML entity names that start with that string, if any"""
77
- function completions end
78
85
completions (str:: AbstractString ) = completions (convert (String, str))
79
86
completions (str:: String ) = StrTables. matchfirst (_tab. nam, str)
80
87
0 commit comments