xrb 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/xrb/parsers.rb +17 -20
- data/ext/extconf.rb +0 -1
- data/ext/xrb/escape.c +1 -1
- data/ext/xrb/escape.h +1 -1
- data/ext/xrb/markup.c +241 -241
- data/ext/xrb/query.c +69 -69
- data/ext/xrb/tag.c +4 -4
- data/ext/xrb/tag.h +1 -1
- data/ext/xrb/template.c +93 -93
- data/ext/xrb/xrb.c +3 -3
- data/ext/xrb/xrb.h +1 -11
- data/lib/xrb/builder.rb +13 -6
- data/lib/xrb/entities.xrb +4 -19
- data/lib/xrb/fallback/markup.rb +1618 -1619
- data/lib/xrb/fallback/markup.rl +0 -1
- data/lib/xrb/fallback/query.rb +515 -515
- data/lib/xrb/fallback/template.rb +787 -787
- data/lib/xrb/parsers.rb +0 -1
- data/lib/xrb/template.rb +10 -46
- data/lib/xrb/version.rb +1 -1
- data/readme.md +42 -1
- data.tar.gz.sig +0 -0
- metadata +2 -3
- metadata.gz.sig +0 -0
- data/lib/xrb/parse_delegate.rb +0 -19
data/ext/xrb/xrb.h
CHANGED
@@ -19,16 +19,6 @@
|
|
19
19
|
#define RB_IMMEDIATE_P IMMEDIATE_P
|
20
20
|
#endif
|
21
21
|
|
22
|
-
// A helper to reserve a specific capacity of data for a buffer.
|
23
|
-
#ifndef HAVE_RB_STR_RESERVE
|
24
|
-
inline VALUE rb_str_reserve(VALUE string, long extra) {
|
25
|
-
long actual = RSTRING_LEN(string);
|
26
|
-
rb_str_resize(string, actual + extra);
|
27
|
-
rb_str_set_len(string, actual);
|
28
|
-
return string;
|
29
|
-
}
|
30
|
-
#endif
|
31
|
-
|
32
22
|
// Modules and classes exposed by XRB.
|
33
23
|
extern VALUE
|
34
24
|
rb_XRB,
|
@@ -84,7 +74,7 @@ static inline VALUE XRB_string(const char * begin, const char * end, rb_encoding
|
|
84
74
|
static inline VALUE XRB_buffer_for(VALUE string) {
|
85
75
|
VALUE buffer = rb_enc_str_new(0, 0, rb_enc_get(string));
|
86
76
|
|
87
|
-
|
77
|
+
rb_str_modify_expand(buffer, RSTRING_LEN(string) + 128);
|
88
78
|
|
89
79
|
return buffer;
|
90
80
|
}
|
data/lib/xrb/builder.rb
CHANGED
@@ -37,6 +37,16 @@ module XRB
|
|
37
37
|
# This is a bit of a hack... but is required for existing specs to pass:
|
38
38
|
self.to_s == other.to_s
|
39
39
|
end
|
40
|
+
|
41
|
+
def >> block
|
42
|
+
if block
|
43
|
+
Template.buffer(block.binding) << self
|
44
|
+
|
45
|
+
return nil
|
46
|
+
else
|
47
|
+
return self
|
48
|
+
end
|
49
|
+
end
|
40
50
|
end
|
41
51
|
|
42
52
|
# A helper to generate fragments of markup.
|
@@ -49,12 +59,9 @@ module XRB
|
|
49
59
|
return Fragment.new(block)
|
50
60
|
end
|
51
61
|
|
52
|
-
|
53
|
-
block.call(output)
|
54
|
-
else
|
55
|
-
block.call(Builder.new(output))
|
56
|
-
end
|
62
|
+
block.call(output)
|
57
63
|
|
64
|
+
# We explicitly return nil here as we don't want to append the output twice.
|
58
65
|
return nil
|
59
66
|
end
|
60
67
|
|
@@ -103,7 +110,7 @@ module XRB
|
|
103
110
|
end
|
104
111
|
|
105
112
|
def doctype(attributes = 'html')
|
106
|
-
@output << "<!
|
113
|
+
@output << "<!doctype #{attributes}>\n"
|
107
114
|
end
|
108
115
|
|
109
116
|
# Begin a block tag.
|
data/lib/xrb/entities.xrb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
module XRB
|
22
7
|
# We only support a small subset of markup entities.
|