html_namespacing 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/html_namespacing/html_namespacing.c +13 -22
- metadata +3 -3
@@ -170,9 +170,9 @@ should_ignore_tag(const char *tag_name, size_t tag_len)
|
|
170
170
|
* "<div class="foo"><span>Hello</span></div><p class="below foo">Goodbye</p>".
|
171
171
|
*
|
172
172
|
* Arguments:
|
173
|
-
* - const char *html: Original HTML string. Must be valid HTML
|
174
|
-
* utf-8.
|
175
|
-
* - int html_len: Length of HTML string.
|
173
|
+
* - const char *html: Original HTML string. Must be valid HTML encoded as
|
174
|
+
* utf-8, \0-terminated.
|
175
|
+
* - int html_len: Length of HTML string, without the \0.
|
176
176
|
* - const char *namespace: Namespace to add. Must be of the form
|
177
177
|
* "[a-zA-Z][-_a-zA-Z0-9]*".
|
178
178
|
* - char **ret: Pointer to return value, which will be newly-allocated. Will
|
@@ -230,7 +230,6 @@ add_namespace_to_html_with_length_and_allocation_strategy(
|
|
230
230
|
const char *html_p;
|
231
231
|
const char *open_tag_name = NULL;
|
232
232
|
size_t open_tag_name_len = 0;
|
233
|
-
size_t num_chars_remaining;
|
234
233
|
int num_tags_open;
|
235
234
|
int open_tag_attribute_is_class_attribute;
|
236
235
|
int open_tag_had_class_attribute;
|
@@ -251,26 +250,21 @@ add_namespace_to_html_with_length_and_allocation_strategy(
|
|
251
250
|
open_tag_attribute_value = NULL;
|
252
251
|
|
253
252
|
while (1) {
|
254
|
-
|
255
|
-
if (num_chars_remaining <= 0) break;
|
253
|
+
if (html_p[0] == 0) break;
|
256
254
|
|
257
255
|
switch (state) {
|
258
256
|
case PARSE_NORMAL:
|
259
257
|
if (*html_p == '<') {
|
260
258
|
ADVANCE(1);
|
261
|
-
if (
|
262
|
-
&& 0 == strncmp("![CDATA[", html_p, 8)) {
|
259
|
+
if (0 == strncmp("![CDATA[", html_p, 8)) {
|
263
260
|
state = PARSE_CDATA;
|
264
|
-
} else if (
|
261
|
+
} else if (html_p[0] == '/') {
|
265
262
|
state = PARSE_CLOSE_TAG;
|
266
|
-
} else if (
|
267
|
-
&& 0 == strncmp("!--", html_p, 3)) {
|
263
|
+
} else if (0 == strncmp("!--", html_p, 3)) {
|
268
264
|
state = PARSE_COMMENT;
|
269
|
-
} else if (
|
270
|
-
&& 0 == strncmp("!DOCTYPE", html_p, 8)) {
|
265
|
+
} else if (0 == strncmp("!DOCTYPE", html_p, 8)) {
|
271
266
|
state = PARSE_DOCTYPE;
|
272
|
-
} else if (
|
273
|
-
&& 0 == strncmp("?xml", html_p, 4)) {
|
267
|
+
} else if (0 == strncmp("?xml", html_p, 4)) {
|
274
268
|
state = PARSE_XML_DECL;
|
275
269
|
} else {
|
276
270
|
open_tag_name = html_p;
|
@@ -313,8 +307,7 @@ add_namespace_to_html_with_length_and_allocation_strategy(
|
|
313
307
|
}
|
314
308
|
ADVANCE(1);
|
315
309
|
} else if (!char_is_whitespace(*html_p)) {
|
316
|
-
if (
|
317
|
-
&& 0 == strncmp(html_p, "class", 5)) {
|
310
|
+
if (0 == strncmp(html_p, "class", 5)) {
|
318
311
|
open_tag_attribute_is_class_attribute = 1;
|
319
312
|
open_tag_had_class_attribute = 1;
|
320
313
|
} else {
|
@@ -370,8 +363,7 @@ add_namespace_to_html_with_length_and_allocation_strategy(
|
|
370
363
|
case PARSE_COMMENT:
|
371
364
|
ADVANCE(1); /* at least one */
|
372
365
|
ADVANCE_UNTIL_ONE_OF_THESE_CHARS("-");
|
373
|
-
if (
|
374
|
-
&& 0 == strncmp("-->", html_p, 3)) {
|
366
|
+
if (0 == strncmp("-->", html_p, 3)) {
|
375
367
|
ADVANCE(3);
|
376
368
|
state = PARSE_NORMAL;
|
377
369
|
}
|
@@ -380,8 +372,7 @@ add_namespace_to_html_with_length_and_allocation_strategy(
|
|
380
372
|
case PARSE_CDATA:
|
381
373
|
ADVANCE(1); /* at least one */
|
382
374
|
ADVANCE_UNTIL_ONE_OF_THESE_CHARS("]");
|
383
|
-
if (
|
384
|
-
&& 0 == strncmp("]]>", html_p, 3)) {
|
375
|
+
if (0 == strncmp("]]>", html_p, 3)) {
|
385
376
|
ADVANCE(3);
|
386
377
|
state = PARSE_NORMAL;
|
387
378
|
}
|
@@ -397,7 +388,7 @@ add_namespace_to_html_with_length_and_allocation_strategy(
|
|
397
388
|
|
398
389
|
if (state != PARSE_NORMAL
|
399
390
|
|| (r_p - r) < html_len
|
400
|
-
||
|
391
|
+
|| html_p != html + html_len
|
401
392
|
|| num_tags_open != 0
|
402
393
|
|| open_tag_attribute_is_class_attribute
|
403
394
|
|| open_tag_attribute_value)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_namespacing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- adamh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-16 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -70,5 +70,5 @@ signing_key:
|
|
70
70
|
specification_version: 3
|
71
71
|
summary: Automatic HTML namespacing
|
72
72
|
test_files:
|
73
|
-
- spec/spec_helper.rb
|
74
73
|
- spec/c_extension_spec.rb
|
74
|
+
- spec/spec_helper.rb
|