berns 2.0.0 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/berns.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'lib/berns/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'berns'
6
+ spec.version = Berns::VERSION
7
+ spec.authors = ['Taylor Beck', 'Evan Lecklider']
8
+ spec.email = ['beck.taylorg@gmail.com', 'evan@lecklider.com']
9
+
10
+ spec.summary = 'A utility library for generating HTML strings.'
11
+ spec.description = 'A utility library for generating HTML strings.'
12
+ spec.homepage = 'https://github.com/evanleck/berns'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
15
+
16
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
18
+ end
19
+
20
+ spec.require_paths = ['lib']
21
+ spec.extensions = %w[ext/berns/extconf.rb]
22
+
23
+ spec.metadata = {
24
+ 'bug_tracker_uri' => 'https://github.com/evanleck/berns/issues',
25
+ 'source_code_uri' => 'https://github.com/evanleck/berns'
26
+ }
27
+
28
+ spec.add_dependency 'cgi'
29
+
30
+ spec.add_development_dependency 'bundler'
31
+ spec.add_development_dependency 'minitest'
32
+ spec.add_development_dependency 'rake'
33
+ spec.add_development_dependency 'rake-compiler'
34
+ spec.add_development_dependency 'rubocop'
35
+ spec.add_development_dependency 'rubocop-minitest'
36
+ spec.add_development_dependency 'rubocop-performance'
37
+ spec.add_development_dependency 'rubocop-rake'
38
+ end
data/ext/berns/berns.c ADDED
@@ -0,0 +1,1060 @@
1
+ #include "ruby.h"
2
+ #include "extconf.h"
3
+
4
+ /*
5
+ * "Safe strcpy" - https://twitter.com/hyc_symas/status/1102573036534972416?s=12
6
+ */
7
+ static char *stecpy(char *destination, const char *source, const char *end) {
8
+ while (*source && destination < end) {
9
+ *destination++ = *source++;
10
+ }
11
+
12
+ if (destination < end) {
13
+ *destination = '\0';
14
+ }
15
+
16
+ return destination;
17
+ }
18
+
19
+ /*
20
+ * Berns.escape_html is effectively a proxy to CGI.escapeHTML so we limit the
21
+ * type to strings.
22
+ */
23
+ static VALUE berns_escape_html(const VALUE self, VALUE string) {
24
+ StringValue(string);
25
+
26
+ const VALUE cgi = rb_const_get(rb_cObject, rb_intern("CGI"));
27
+ const VALUE escape = rb_intern("escapeHTML");
28
+
29
+ return rb_funcall(cgi, escape, 1, string);
30
+ }
31
+
32
+ static VALUE berns_to_attribute(const VALUE self, VALUE attribute, const VALUE value) {
33
+ const VALUE empty = rb_utf8_str_new_cstr("");
34
+
35
+ VALUE escaped;
36
+ VALUE key;
37
+ VALUE keys;
38
+ VALUE length;
39
+ VALUE rstring;
40
+ VALUE subattr;
41
+ VALUE subkey;
42
+ VALUE subvalue;
43
+
44
+ switch(TYPE(attribute)) {
45
+ case T_STRING:
46
+ break;
47
+ case T_SYMBOL:
48
+ attribute = rb_sym_to_s(attribute);
49
+ break;
50
+ default:
51
+ rb_raise(rb_eTypeError, "Berns.to_attribute attributes must be Strings or Symbols.");
52
+ break;
53
+ }
54
+
55
+ const char *close = "\"";
56
+ const char *dash = "-";
57
+ const char *equals = "=\"";
58
+ const char *space = " ";
59
+
60
+ const size_t clen = strlen(close);
61
+ const size_t dlen = strlen(dash);
62
+ const size_t eqlen = strlen(equals);
63
+ const size_t splen = strlen(space);
64
+
65
+ switch(TYPE(value)) {
66
+ case T_NIL:
67
+ case T_TRUE:
68
+ return attribute;
69
+ case T_FALSE:
70
+ return empty;
71
+ case T_HASH:
72
+ keys = rb_funcall(value, rb_intern("keys"), 0);
73
+ length = RARRAY_LEN(keys);
74
+
75
+ if (length == 0) {
76
+ return rb_utf8_str_new_cstr("");
77
+ }
78
+
79
+ char *substring = NULL;
80
+ size_t size = 0;
81
+
82
+ for (unsigned int i = 0; i < length; i++) {
83
+ key = rb_ary_entry(keys, i);
84
+ subvalue = rb_hash_aref(value, key);
85
+
86
+ switch(TYPE(key)) {
87
+ case T_NIL:
88
+ subkey = empty;
89
+ break;
90
+ case T_STRING:
91
+ subkey = key;
92
+ break;
93
+ case T_SYMBOL:
94
+ subkey = rb_sym_to_s(key);
95
+ break;
96
+ default:
97
+ if (substring != NULL) {
98
+ free(substring);
99
+ }
100
+
101
+ rb_raise(rb_eTypeError, "Berns.to_attribute value keys must be Strings or Symbols.");
102
+ break;
103
+ }
104
+
105
+ size_t total = RSTRING_LEN(attribute) + 1;
106
+
107
+ if (RSTRING_LEN(subkey) > 0) {
108
+ total = RSTRING_LEN(attribute) + dlen + RSTRING_LEN(subkey) + 1;
109
+ }
110
+
111
+ char subname[total];
112
+ char *ptr;
113
+ char *end = subname + sizeof(subname);
114
+
115
+ ptr = stecpy(subname, RSTRING_PTR(attribute), end);
116
+
117
+ if (RSTRING_LEN(subkey) > 0) {
118
+ ptr = stecpy(ptr, dash, end);
119
+ }
120
+
121
+ stecpy(ptr, RSTRING_PTR(subkey), end);
122
+
123
+ subattr = berns_to_attribute(self, rb_utf8_str_new_cstr(subname), subvalue);
124
+ size_t subattrlen = RSTRING_LEN(subattr);
125
+
126
+ if (i > 0) {
127
+ size = size + splen + subattrlen;
128
+
129
+ char *tmp = realloc(substring, size + 1);
130
+
131
+ if (tmp == NULL) {
132
+ rb_raise(rb_eNoMemError, "Berns.to_attribute could not allocate sufficient memory.");
133
+ }
134
+
135
+ substring = tmp;
136
+
137
+ stecpy(substring + size - splen - subattrlen, space, substring + size);
138
+ stecpy(substring + size - subattrlen, RSTRING_PTR(subattr), substring + size + 1);
139
+ } else {
140
+ size = size + subattrlen;
141
+ char *tmp = realloc(substring, size + 1);
142
+
143
+ if (tmp == NULL) {
144
+ rb_raise(rb_eNoMemError, "Berns.to_attribute could not allocate sufficient memory.");
145
+ }
146
+
147
+ substring = tmp;
148
+
149
+ stecpy(substring + size - subattrlen, RSTRING_PTR(subattr), substring + size + 1);
150
+ }
151
+ }
152
+
153
+ rstring = rb_utf8_str_new_cstr(substring);
154
+ free(substring);
155
+
156
+ return rstring;
157
+ default:
158
+ switch (TYPE(value)) {
159
+ case T_STRING:
160
+ escaped = berns_escape_html(self, value);
161
+ break;
162
+ case T_SYMBOL:
163
+ escaped = berns_escape_html(self, rb_sym_to_s(value));
164
+ break;
165
+ default:
166
+ escaped = berns_escape_html(self, rb_funcall(value, rb_intern("to_s"), 0));
167
+ break;
168
+ }
169
+
170
+ char string[RSTRING_LEN(attribute) + eqlen + RSTRING_LEN(escaped) + clen + 1];
171
+ char *ptr;
172
+ char *end = string + sizeof(string);
173
+
174
+ ptr = stecpy(string, RSTRING_PTR(attribute), end);
175
+ ptr = stecpy(ptr, equals, end);
176
+ ptr = stecpy(ptr, RSTRING_PTR(escaped), end);
177
+ stecpy(ptr, close, end);
178
+
179
+ return rb_utf8_str_new_cstr(string);
180
+ }
181
+ }
182
+
183
+ /* Expects a Ruby Hash as a single argument. */
184
+ static VALUE berns_to_attributes(const VALUE self, const VALUE attributes) {
185
+ Check_Type(attributes, T_HASH);
186
+
187
+ VALUE key;
188
+ VALUE attribute;
189
+ VALUE rstring;
190
+
191
+ const VALUE keys = rb_funcall(attributes, rb_intern("keys"), 0);
192
+ const VALUE length = RARRAY_LEN(keys);
193
+
194
+ if (length == 0) {
195
+ return rb_utf8_str_new_cstr("");
196
+ }
197
+
198
+ char *string = NULL;
199
+ size_t size = 0; /* IN BYTES */
200
+
201
+ const char *space = " ";
202
+ const size_t splen = strlen(space);
203
+
204
+ size_t alen;
205
+
206
+ for (unsigned int i = 0; i < length; i++) {
207
+ key = rb_ary_entry(keys, i);
208
+ attribute = berns_to_attribute(self, key, rb_hash_aref(attributes, key));
209
+ alen = RSTRING_LEN(attribute);
210
+
211
+ if (i > 0) {
212
+ char *tmp = realloc(string, size + alen + splen + 1);
213
+
214
+ if (tmp == NULL) {
215
+ rb_raise(rb_eNoMemError, "Berns.to_attributes could not allocate sufficient memory.");
216
+ }
217
+
218
+ string = tmp;
219
+
220
+ stecpy(string + size, space, string + size + splen);
221
+ stecpy(string + size + splen, RSTRING_PTR(attribute), string + size + splen + alen + 1);
222
+ size = size + splen + alen;
223
+ } else {
224
+ char *tmp = realloc(string, size + alen + 1);
225
+
226
+ if (tmp == NULL) {
227
+ rb_raise(rb_eNoMemError, "Berns.to_attributes could not allocate sufficient memory.");
228
+ }
229
+
230
+ string = tmp;
231
+
232
+ stecpy(string + size, RSTRING_PTR(attribute), string + size + alen + 1);
233
+ size = size + alen;
234
+ }
235
+ }
236
+
237
+ rstring = rb_utf8_str_new_cstr(string);
238
+ free(string);
239
+
240
+ return rstring;
241
+ }
242
+
243
+ static VALUE berns_internal_void(VALUE tag, VALUE attributes) {
244
+ const VALUE berns = rb_const_get(rb_cObject, rb_intern("Berns"));
245
+
246
+ switch(TYPE(tag)) {
247
+ case T_STRING:
248
+ break;
249
+ case T_SYMBOL:
250
+ tag = rb_sym_to_s(tag);
251
+ break;
252
+ default:
253
+ rb_raise(rb_eTypeError, "Berns.void elements must be a String or Symbol.");
254
+ break;
255
+ }
256
+
257
+ const char *open = "<";
258
+ const char *close = ">";
259
+ const char *space = " ";
260
+
261
+ const size_t olen = strlen(open);
262
+ const size_t clen = strlen(close);
263
+ const size_t slen = strlen(space);
264
+
265
+ size_t tlen = RSTRING_LEN(tag);
266
+ size_t total;
267
+ size_t alen = 0;
268
+
269
+ if (TYPE(attributes) != T_IMEMO) {
270
+ attributes = berns_to_attributes(berns, attributes);
271
+ alen = RSTRING_LEN(attributes);
272
+
273
+ if (alen > 0) {
274
+ total = olen + tlen + slen + alen + clen + 1;
275
+ } else {
276
+ total = olen + tlen + clen + 1;
277
+ }
278
+ } else {
279
+ total = olen + tlen + clen + 1;
280
+ }
281
+
282
+ char string[total];
283
+ char *ptr, *end = string + sizeof(string);
284
+
285
+ ptr = stecpy(string, open, end);
286
+ ptr = stecpy(ptr, RSTRING_PTR(tag), end);
287
+
288
+ if (TYPE(attributes) != T_IMEMO && alen > 0) {
289
+ ptr = stecpy(ptr, space, end);
290
+ ptr = stecpy(ptr, RSTRING_PTR(attributes), end);
291
+ }
292
+
293
+ stecpy(ptr, close, end);
294
+
295
+ return rb_utf8_str_new_cstr(string);
296
+ }
297
+
298
+ static VALUE berns_internal_element(VALUE tag, VALUE attributes) {
299
+ const VALUE berns = rb_const_get(rb_cObject, rb_intern("Berns"));
300
+
301
+ VALUE content;
302
+
303
+ switch(TYPE(tag)) {
304
+ case T_STRING:
305
+ break;
306
+ case T_SYMBOL:
307
+ tag = rb_sym_to_s(tag);
308
+ break;
309
+ default:
310
+ rb_raise(rb_eTypeError, "Berns.element elements must be a String or Symbol.");
311
+ break;
312
+ }
313
+
314
+ if (rb_block_given_p()) {
315
+ content = rb_yield(Qnil);
316
+
317
+ if (TYPE(content) == T_NIL) {
318
+ content = rb_utf8_str_new_cstr("");
319
+ }
320
+ } else {
321
+ content = rb_utf8_str_new_cstr("");
322
+ }
323
+
324
+ StringValue(content);
325
+
326
+ const char *open = "<";
327
+ const char *close = ">";
328
+ const char *slash = "/";
329
+ const char *space = " ";
330
+
331
+ const size_t olen = strlen(open);
332
+ const size_t clen = strlen(close);
333
+ const size_t sllen = strlen(slash);
334
+ const size_t slen = strlen(space);
335
+
336
+ size_t tlen = RSTRING_LEN(tag);
337
+ size_t conlen = RSTRING_LEN(content);
338
+ size_t total = olen + tlen + clen + conlen + olen + sllen + tlen + clen + 1;
339
+
340
+ if (TYPE(attributes) != T_IMEMO) {
341
+ attributes = berns_to_attributes(berns, attributes);
342
+ total = total + slen + RSTRING_LEN(attributes);
343
+ }
344
+
345
+ char string[total];
346
+ char *ptr;
347
+ char *end = string + sizeof(string);
348
+
349
+ ptr = stecpy(string, open, end);
350
+ ptr = stecpy(ptr, RSTRING_PTR(tag), end);
351
+
352
+ if (TYPE(attributes) != T_IMEMO) {
353
+ ptr = stecpy(ptr, space, end);
354
+ ptr = stecpy(ptr, RSTRING_PTR(attributes), end);
355
+ }
356
+
357
+ ptr = stecpy(ptr, close, end);
358
+ ptr = stecpy(ptr, RSTRING_PTR(content), end);
359
+ ptr = stecpy(ptr, open, end);
360
+ ptr = stecpy(ptr, slash, end);
361
+ ptr = stecpy(ptr, RSTRING_PTR(tag), end);
362
+ stecpy(ptr, close, end);
363
+
364
+ return rb_utf8_str_new_cstr(string);
365
+ }
366
+
367
+ static VALUE berns_void_element(int argc, VALUE *argv, VALUE self) {
368
+ rb_check_arity(argc, 1, 2);
369
+ return berns_internal_void(argv[0], argv[1]);
370
+ }
371
+
372
+ static VALUE berns_area_element(int argc, VALUE *argv, VALUE self) {
373
+ rb_check_arity(argc, 0, 1);
374
+ return berns_internal_void(rb_utf8_str_new_cstr("area"), argv[0]);
375
+ }
376
+
377
+ static VALUE berns_base_element(int argc, VALUE *argv, VALUE self) {
378
+ rb_check_arity(argc, 0, 1);
379
+ return berns_internal_void(rb_utf8_str_new_cstr("base"), argv[0]);
380
+ }
381
+
382
+ static VALUE berns_br_element(int argc, VALUE *argv, VALUE self) {
383
+ rb_check_arity(argc, 0, 1);
384
+ return berns_internal_void(rb_utf8_str_new_cstr("br"), argv[0]);
385
+ }
386
+
387
+ static VALUE berns_col_element(int argc, VALUE *argv, VALUE self) {
388
+ rb_check_arity(argc, 0, 1);
389
+ return berns_internal_void(rb_utf8_str_new_cstr("col"), argv[0]);
390
+ }
391
+
392
+ static VALUE berns_embed_element(int argc, VALUE *argv, VALUE self) {
393
+ rb_check_arity(argc, 0, 1);
394
+ return berns_internal_void(rb_utf8_str_new_cstr("embed"), argv[0]);
395
+ }
396
+
397
+ static VALUE berns_hr_element(int argc, VALUE *argv, VALUE self) {
398
+ rb_check_arity(argc, 0, 1);
399
+ return berns_internal_void(rb_utf8_str_new_cstr("hr"), argv[0]);
400
+ }
401
+
402
+ static VALUE berns_img_element(int argc, VALUE *argv, VALUE self) {
403
+ rb_check_arity(argc, 0, 1);
404
+ return berns_internal_void(rb_utf8_str_new_cstr("img"), argv[0]);
405
+ }
406
+
407
+ static VALUE berns_input_element(int argc, VALUE *argv, VALUE self) {
408
+ rb_check_arity(argc, 0, 1);
409
+ return berns_internal_void(rb_utf8_str_new_cstr("input"), argv[0]);
410
+ }
411
+
412
+ static VALUE berns_link_element(int argc, VALUE *argv, VALUE self) {
413
+ rb_check_arity(argc, 0, 1);
414
+ return berns_internal_void(rb_utf8_str_new_cstr("link"), argv[0]);
415
+ }
416
+
417
+ static VALUE berns_menuitem_element(int argc, VALUE *argv, VALUE self) {
418
+ rb_check_arity(argc, 0, 1);
419
+ return berns_internal_void(rb_utf8_str_new_cstr("menuitem"), argv[0]);
420
+ }
421
+
422
+ static VALUE berns_meta_element(int argc, VALUE *argv, VALUE self) {
423
+ rb_check_arity(argc, 0, 1);
424
+ return berns_internal_void(rb_utf8_str_new_cstr("meta"), argv[0]);
425
+ }
426
+
427
+ static VALUE berns_param_element(int argc, VALUE *argv, VALUE self) {
428
+ rb_check_arity(argc, 0, 1);
429
+ return berns_internal_void(rb_utf8_str_new_cstr("param"), argv[0]);
430
+ }
431
+
432
+ static VALUE berns_source_element(int argc, VALUE *argv, VALUE self) {
433
+ rb_check_arity(argc, 0, 1);
434
+ return berns_internal_void(rb_utf8_str_new_cstr("source"), argv[0]);
435
+ }
436
+
437
+ static VALUE berns_track_element(int argc, VALUE *argv, VALUE self) {
438
+ rb_check_arity(argc, 0, 1);
439
+ return berns_internal_void(rb_utf8_str_new_cstr("track"), argv[0]);
440
+ }
441
+
442
+ static VALUE berns_wbr_element(int argc, VALUE *argv, VALUE self) {
443
+ rb_check_arity(argc, 0, 1);
444
+ return berns_internal_void(rb_utf8_str_new_cstr("wbr"), argv[0]);
445
+ }
446
+
447
+ static VALUE berns_element(int argc, VALUE* argv, VALUE self) {
448
+ rb_check_arity(argc, 1, 2);
449
+ return berns_internal_element(argv[0], argv[1]);
450
+ }
451
+
452
+ static VALUE berns_a_element(int argc, VALUE* argv, VALUE self) {
453
+ rb_check_arity(argc, 0, 1);
454
+ return berns_internal_element(rb_utf8_str_new_cstr("a"), argv[0]);
455
+ }
456
+
457
+ static VALUE berns_abbr_element(int argc, VALUE* argv, VALUE self) {
458
+ rb_check_arity(argc, 0, 1);
459
+ return berns_internal_element(rb_utf8_str_new_cstr("abbr"), argv[0]);
460
+ }
461
+
462
+ static VALUE berns_address_element(int argc, VALUE* argv, VALUE self) {
463
+ rb_check_arity(argc, 0, 1);
464
+ return berns_internal_element(rb_utf8_str_new_cstr("address"), argv[0]);
465
+ }
466
+
467
+ static VALUE berns_article_element(int argc, VALUE* argv, VALUE self) {
468
+ rb_check_arity(argc, 0, 1);
469
+ return berns_internal_element(rb_utf8_str_new_cstr("article"), argv[0]);
470
+ }
471
+
472
+ static VALUE berns_aside_element(int argc, VALUE* argv, VALUE self) {
473
+ rb_check_arity(argc, 0, 1);
474
+ return berns_internal_element(rb_utf8_str_new_cstr("aside"), argv[0]);
475
+ }
476
+
477
+ static VALUE berns_audio_element(int argc, VALUE* argv, VALUE self) {
478
+ rb_check_arity(argc, 0, 1);
479
+ return berns_internal_element(rb_utf8_str_new_cstr("audio"), argv[0]);
480
+ }
481
+
482
+ static VALUE berns_b_element(int argc, VALUE* argv, VALUE self) {
483
+ rb_check_arity(argc, 0, 1);
484
+ return berns_internal_element(rb_utf8_str_new_cstr("b"), argv[0]);
485
+ }
486
+
487
+ static VALUE berns_bdi_element(int argc, VALUE* argv, VALUE self) {
488
+ rb_check_arity(argc, 0, 1);
489
+ return berns_internal_element(rb_utf8_str_new_cstr("bdi"), argv[0]);
490
+ }
491
+
492
+ static VALUE berns_bdo_element(int argc, VALUE* argv, VALUE self) {
493
+ rb_check_arity(argc, 0, 1);
494
+ return berns_internal_element(rb_utf8_str_new_cstr("bdo"), argv[0]);
495
+ }
496
+
497
+ static VALUE berns_blockquote_element(int argc, VALUE* argv, VALUE self) {
498
+ rb_check_arity(argc, 0, 1);
499
+ return berns_internal_element(rb_utf8_str_new_cstr("blockquote"), argv[0]);
500
+ }
501
+
502
+ static VALUE berns_body_element(int argc, VALUE* argv, VALUE self) {
503
+ rb_check_arity(argc, 0, 1);
504
+ return berns_internal_element(rb_utf8_str_new_cstr("body"), argv[0]);
505
+ }
506
+
507
+ static VALUE berns_button_element(int argc, VALUE* argv, VALUE self) {
508
+ rb_check_arity(argc, 0, 1);
509
+ return berns_internal_element(rb_utf8_str_new_cstr("button"), argv[0]);
510
+ }
511
+
512
+ static VALUE berns_canvas_element(int argc, VALUE* argv, VALUE self) {
513
+ rb_check_arity(argc, 0, 1);
514
+ return berns_internal_element(rb_utf8_str_new_cstr("canvas"), argv[0]);
515
+ }
516
+
517
+ static VALUE berns_caption_element(int argc, VALUE* argv, VALUE self) {
518
+ rb_check_arity(argc, 0, 1);
519
+ return berns_internal_element(rb_utf8_str_new_cstr("caption"), argv[0]);
520
+ }
521
+
522
+ static VALUE berns_cite_element(int argc, VALUE* argv, VALUE self) {
523
+ rb_check_arity(argc, 0, 1);
524
+ return berns_internal_element(rb_utf8_str_new_cstr("cite"), argv[0]);
525
+ }
526
+
527
+ static VALUE berns_code_element(int argc, VALUE* argv, VALUE self) {
528
+ rb_check_arity(argc, 0, 1);
529
+ return berns_internal_element(rb_utf8_str_new_cstr("code"), argv[0]);
530
+ }
531
+
532
+ static VALUE berns_colgroup_element(int argc, VALUE* argv, VALUE self) {
533
+ rb_check_arity(argc, 0, 1);
534
+ return berns_internal_element(rb_utf8_str_new_cstr("colgroup"), argv[0]);
535
+ }
536
+
537
+ static VALUE berns_datalist_element(int argc, VALUE* argv, VALUE self) {
538
+ rb_check_arity(argc, 0, 1);
539
+ return berns_internal_element(rb_utf8_str_new_cstr("datalist"), argv[0]);
540
+ }
541
+
542
+ static VALUE berns_dd_element(int argc, VALUE* argv, VALUE self) {
543
+ rb_check_arity(argc, 0, 1);
544
+ return berns_internal_element(rb_utf8_str_new_cstr("dd"), argv[0]);
545
+ }
546
+
547
+ static VALUE berns_del_element(int argc, VALUE* argv, VALUE self) {
548
+ rb_check_arity(argc, 0, 1);
549
+ return berns_internal_element(rb_utf8_str_new_cstr("del"), argv[0]);
550
+ }
551
+
552
+ static VALUE berns_details_element(int argc, VALUE* argv, VALUE self) {
553
+ rb_check_arity(argc, 0, 1);
554
+ return berns_internal_element(rb_utf8_str_new_cstr("details"), argv[0]);
555
+ }
556
+
557
+ static VALUE berns_dfn_element(int argc, VALUE* argv, VALUE self) {
558
+ rb_check_arity(argc, 0, 1);
559
+ return berns_internal_element(rb_utf8_str_new_cstr("dfn"), argv[0]);
560
+ }
561
+
562
+ static VALUE berns_dialog_element(int argc, VALUE* argv, VALUE self) {
563
+ rb_check_arity(argc, 0, 1);
564
+ return berns_internal_element(rb_utf8_str_new_cstr("dialog"), argv[0]);
565
+ }
566
+
567
+ static VALUE berns_div_element(int argc, VALUE* argv, VALUE self) {
568
+ rb_check_arity(argc, 0, 1);
569
+ return berns_internal_element(rb_utf8_str_new_cstr("div"), argv[0]);
570
+ }
571
+
572
+ static VALUE berns_dl_element(int argc, VALUE* argv, VALUE self) {
573
+ rb_check_arity(argc, 0, 1);
574
+ return berns_internal_element(rb_utf8_str_new_cstr("dl"), argv[0]);
575
+ }
576
+
577
+ static VALUE berns_dt_element(int argc, VALUE* argv, VALUE self) {
578
+ rb_check_arity(argc, 0, 1);
579
+ return berns_internal_element(rb_utf8_str_new_cstr("dt"), argv[0]);
580
+ }
581
+
582
+ static VALUE berns_em_element(int argc, VALUE* argv, VALUE self) {
583
+ rb_check_arity(argc, 0, 1);
584
+ return berns_internal_element(rb_utf8_str_new_cstr("em"), argv[0]);
585
+ }
586
+
587
+ static VALUE berns_fieldset_element(int argc, VALUE* argv, VALUE self) {
588
+ rb_check_arity(argc, 0, 1);
589
+ return berns_internal_element(rb_utf8_str_new_cstr("fieldset"), argv[0]);
590
+ }
591
+
592
+ static VALUE berns_figcaption_element(int argc, VALUE* argv, VALUE self) {
593
+ rb_check_arity(argc, 0, 1);
594
+ return berns_internal_element(rb_utf8_str_new_cstr("figcaption"), argv[0]);
595
+ }
596
+
597
+ static VALUE berns_figure_element(int argc, VALUE* argv, VALUE self) {
598
+ rb_check_arity(argc, 0, 1);
599
+ return berns_internal_element(rb_utf8_str_new_cstr("figure"), argv[0]);
600
+ }
601
+
602
+ static VALUE berns_footer_element(int argc, VALUE* argv, VALUE self) {
603
+ rb_check_arity(argc, 0, 1);
604
+ return berns_internal_element(rb_utf8_str_new_cstr("footer"), argv[0]);
605
+ }
606
+
607
+ static VALUE berns_form_element(int argc, VALUE* argv, VALUE self) {
608
+ rb_check_arity(argc, 0, 1);
609
+ return berns_internal_element(rb_utf8_str_new_cstr("form"), argv[0]);
610
+ }
611
+
612
+ static VALUE berns_h1_element(int argc, VALUE* argv, VALUE self) {
613
+ rb_check_arity(argc, 0, 1);
614
+ return berns_internal_element(rb_utf8_str_new_cstr("h1"), argv[0]);
615
+ }
616
+
617
+ static VALUE berns_h2_element(int argc, VALUE* argv, VALUE self) {
618
+ rb_check_arity(argc, 0, 1);
619
+ return berns_internal_element(rb_utf8_str_new_cstr("h2"), argv[0]);
620
+ }
621
+
622
+ static VALUE berns_h3_element(int argc, VALUE* argv, VALUE self) {
623
+ rb_check_arity(argc, 0, 1);
624
+ return berns_internal_element(rb_utf8_str_new_cstr("h3"), argv[0]);
625
+ }
626
+
627
+ static VALUE berns_h4_element(int argc, VALUE* argv, VALUE self) {
628
+ rb_check_arity(argc, 0, 1);
629
+ return berns_internal_element(rb_utf8_str_new_cstr("h4"), argv[0]);
630
+ }
631
+
632
+ static VALUE berns_h5_element(int argc, VALUE* argv, VALUE self) {
633
+ rb_check_arity(argc, 0, 1);
634
+ return berns_internal_element(rb_utf8_str_new_cstr("h5"), argv[0]);
635
+ }
636
+
637
+ static VALUE berns_h6_element(int argc, VALUE* argv, VALUE self) {
638
+ rb_check_arity(argc, 0, 1);
639
+ return berns_internal_element(rb_utf8_str_new_cstr("h6"), argv[0]);
640
+ }
641
+
642
+ static VALUE berns_head_element(int argc, VALUE* argv, VALUE self) {
643
+ rb_check_arity(argc, 0, 1);
644
+ return berns_internal_element(rb_utf8_str_new_cstr("head"), argv[0]);
645
+ }
646
+
647
+ static VALUE berns_header_element(int argc, VALUE* argv, VALUE self) {
648
+ rb_check_arity(argc, 0, 1);
649
+ return berns_internal_element(rb_utf8_str_new_cstr("header"), argv[0]);
650
+ }
651
+
652
+ static VALUE berns_html_element(int argc, VALUE* argv, VALUE self) {
653
+ rb_check_arity(argc, 0, 1);
654
+ return berns_internal_element(rb_utf8_str_new_cstr("html"), argv[0]);
655
+ }
656
+
657
+ static VALUE berns_i_element(int argc, VALUE* argv, VALUE self) {
658
+ rb_check_arity(argc, 0, 1);
659
+ return berns_internal_element(rb_utf8_str_new_cstr("i"), argv[0]);
660
+ }
661
+
662
+ static VALUE berns_iframe_element(int argc, VALUE* argv, VALUE self) {
663
+ rb_check_arity(argc, 0, 1);
664
+ return berns_internal_element(rb_utf8_str_new_cstr("iframe"), argv[0]);
665
+ }
666
+
667
+ static VALUE berns_ins_element(int argc, VALUE* argv, VALUE self) {
668
+ rb_check_arity(argc, 0, 1);
669
+ return berns_internal_element(rb_utf8_str_new_cstr("ins"), argv[0]);
670
+ }
671
+
672
+ static VALUE berns_kbd_element(int argc, VALUE* argv, VALUE self) {
673
+ rb_check_arity(argc, 0, 1);
674
+ return berns_internal_element(rb_utf8_str_new_cstr("kbd"), argv[0]);
675
+ }
676
+
677
+ static VALUE berns_label_element(int argc, VALUE* argv, VALUE self) {
678
+ rb_check_arity(argc, 0, 1);
679
+ return berns_internal_element(rb_utf8_str_new_cstr("label"), argv[0]);
680
+ }
681
+
682
+ static VALUE berns_legend_element(int argc, VALUE* argv, VALUE self) {
683
+ rb_check_arity(argc, 0, 1);
684
+ return berns_internal_element(rb_utf8_str_new_cstr("legend"), argv[0]);
685
+ }
686
+
687
+ static VALUE berns_li_element(int argc, VALUE* argv, VALUE self) {
688
+ rb_check_arity(argc, 0, 1);
689
+ return berns_internal_element(rb_utf8_str_new_cstr("li"), argv[0]);
690
+ }
691
+
692
+ static VALUE berns_main_element(int argc, VALUE* argv, VALUE self) {
693
+ rb_check_arity(argc, 0, 1);
694
+ return berns_internal_element(rb_utf8_str_new_cstr("main"), argv[0]);
695
+ }
696
+
697
+ static VALUE berns_map_element(int argc, VALUE* argv, VALUE self) {
698
+ rb_check_arity(argc, 0, 1);
699
+ return berns_internal_element(rb_utf8_str_new_cstr("map"), argv[0]);
700
+ }
701
+
702
+ static VALUE berns_mark_element(int argc, VALUE* argv, VALUE self) {
703
+ rb_check_arity(argc, 0, 1);
704
+ return berns_internal_element(rb_utf8_str_new_cstr("mark"), argv[0]);
705
+ }
706
+
707
+ static VALUE berns_menu_element(int argc, VALUE* argv, VALUE self) {
708
+ rb_check_arity(argc, 0, 1);
709
+ return berns_internal_element(rb_utf8_str_new_cstr("menu"), argv[0]);
710
+ }
711
+
712
+ static VALUE berns_meter_element(int argc, VALUE* argv, VALUE self) {
713
+ rb_check_arity(argc, 0, 1);
714
+ return berns_internal_element(rb_utf8_str_new_cstr("meter"), argv[0]);
715
+ }
716
+
717
+ static VALUE berns_nav_element(int argc, VALUE* argv, VALUE self) {
718
+ rb_check_arity(argc, 0, 1);
719
+ return berns_internal_element(rb_utf8_str_new_cstr("nav"), argv[0]);
720
+ }
721
+
722
+ static VALUE berns_noscript_element(int argc, VALUE* argv, VALUE self) {
723
+ rb_check_arity(argc, 0, 1);
724
+ return berns_internal_element(rb_utf8_str_new_cstr("noscript"), argv[0]);
725
+ }
726
+
727
+ static VALUE berns_object_element(int argc, VALUE* argv, VALUE self) {
728
+ rb_check_arity(argc, 0, 1);
729
+ return berns_internal_element(rb_utf8_str_new_cstr("object"), argv[0]);
730
+ }
731
+
732
+ static VALUE berns_ol_element(int argc, VALUE* argv, VALUE self) {
733
+ rb_check_arity(argc, 0, 1);
734
+ return berns_internal_element(rb_utf8_str_new_cstr("ol"), argv[0]);
735
+ }
736
+
737
+ static VALUE berns_optgroup_element(int argc, VALUE* argv, VALUE self) {
738
+ rb_check_arity(argc, 0, 1);
739
+ return berns_internal_element(rb_utf8_str_new_cstr("optgroup"), argv[0]);
740
+ }
741
+
742
+ static VALUE berns_option_element(int argc, VALUE* argv, VALUE self) {
743
+ rb_check_arity(argc, 0, 1);
744
+ return berns_internal_element(rb_utf8_str_new_cstr("option"), argv[0]);
745
+ }
746
+
747
+ static VALUE berns_output_element(int argc, VALUE* argv, VALUE self) {
748
+ rb_check_arity(argc, 0, 1);
749
+ return berns_internal_element(rb_utf8_str_new_cstr("output"), argv[0]);
750
+ }
751
+
752
+ static VALUE berns_p_element(int argc, VALUE* argv, VALUE self) {
753
+ rb_check_arity(argc, 0, 1);
754
+ return berns_internal_element(rb_utf8_str_new_cstr("p"), argv[0]);
755
+ }
756
+
757
+ static VALUE berns_picture_element(int argc, VALUE* argv, VALUE self) {
758
+ rb_check_arity(argc, 0, 1);
759
+ return berns_internal_element(rb_utf8_str_new_cstr("picture"), argv[0]);
760
+ }
761
+
762
+ static VALUE berns_pre_element(int argc, VALUE* argv, VALUE self) {
763
+ rb_check_arity(argc, 0, 1);
764
+ return berns_internal_element(rb_utf8_str_new_cstr("pre"), argv[0]);
765
+ }
766
+
767
+ static VALUE berns_progress_element(int argc, VALUE* argv, VALUE self) {
768
+ rb_check_arity(argc, 0, 1);
769
+ return berns_internal_element(rb_utf8_str_new_cstr("progress"), argv[0]);
770
+ }
771
+
772
+ static VALUE berns_q_element(int argc, VALUE* argv, VALUE self) {
773
+ rb_check_arity(argc, 0, 1);
774
+ return berns_internal_element(rb_utf8_str_new_cstr("q"), argv[0]);
775
+ }
776
+
777
+ static VALUE berns_rp_element(int argc, VALUE* argv, VALUE self) {
778
+ rb_check_arity(argc, 0, 1);
779
+ return berns_internal_element(rb_utf8_str_new_cstr("rp"), argv[0]);
780
+ }
781
+
782
+ static VALUE berns_rt_element(int argc, VALUE* argv, VALUE self) {
783
+ rb_check_arity(argc, 0, 1);
784
+ return berns_internal_element(rb_utf8_str_new_cstr("rt"), argv[0]);
785
+ }
786
+
787
+ static VALUE berns_ruby_element(int argc, VALUE* argv, VALUE self) {
788
+ rb_check_arity(argc, 0, 1);
789
+ return berns_internal_element(rb_utf8_str_new_cstr("ruby"), argv[0]);
790
+ }
791
+
792
+ static VALUE berns_s_element(int argc, VALUE* argv, VALUE self) {
793
+ rb_check_arity(argc, 0, 1);
794
+ return berns_internal_element(rb_utf8_str_new_cstr("s"), argv[0]);
795
+ }
796
+
797
+ static VALUE berns_samp_element(int argc, VALUE* argv, VALUE self) {
798
+ rb_check_arity(argc, 0, 1);
799
+ return berns_internal_element(rb_utf8_str_new_cstr("samp"), argv[0]);
800
+ }
801
+
802
+ static VALUE berns_script_element(int argc, VALUE* argv, VALUE self) {
803
+ rb_check_arity(argc, 0, 1);
804
+ return berns_internal_element(rb_utf8_str_new_cstr("script"), argv[0]);
805
+ }
806
+
807
+ static VALUE berns_section_element(int argc, VALUE* argv, VALUE self) {
808
+ rb_check_arity(argc, 0, 1);
809
+ return berns_internal_element(rb_utf8_str_new_cstr("section"), argv[0]);
810
+ }
811
+
812
+ static VALUE berns_select_element(int argc, VALUE* argv, VALUE self) {
813
+ rb_check_arity(argc, 0, 1);
814
+ return berns_internal_element(rb_utf8_str_new_cstr("select"), argv[0]);
815
+ }
816
+
817
+ static VALUE berns_small_element(int argc, VALUE* argv, VALUE self) {
818
+ rb_check_arity(argc, 0, 1);
819
+ return berns_internal_element(rb_utf8_str_new_cstr("small"), argv[0]);
820
+ }
821
+
822
+ static VALUE berns_span_element(int argc, VALUE* argv, VALUE self) {
823
+ rb_check_arity(argc, 0, 1);
824
+ return berns_internal_element(rb_utf8_str_new_cstr("span"), argv[0]);
825
+ }
826
+
827
+ static VALUE berns_strong_element(int argc, VALUE* argv, VALUE self) {
828
+ rb_check_arity(argc, 0, 1);
829
+ return berns_internal_element(rb_utf8_str_new_cstr("strong"), argv[0]);
830
+ }
831
+
832
+ static VALUE berns_style_element(int argc, VALUE* argv, VALUE self) {
833
+ rb_check_arity(argc, 0, 1);
834
+ return berns_internal_element(rb_utf8_str_new_cstr("style"), argv[0]);
835
+ }
836
+
837
+ static VALUE berns_sub_element(int argc, VALUE* argv, VALUE self) {
838
+ rb_check_arity(argc, 0, 1);
839
+ return berns_internal_element(rb_utf8_str_new_cstr("sub"), argv[0]);
840
+ }
841
+
842
+ static VALUE berns_summary_element(int argc, VALUE* argv, VALUE self) {
843
+ rb_check_arity(argc, 0, 1);
844
+ return berns_internal_element(rb_utf8_str_new_cstr("summary"), argv[0]);
845
+ }
846
+
847
+ static VALUE berns_table_element(int argc, VALUE* argv, VALUE self) {
848
+ rb_check_arity(argc, 0, 1);
849
+ return berns_internal_element(rb_utf8_str_new_cstr("table"), argv[0]);
850
+ }
851
+
852
+ static VALUE berns_tbody_element(int argc, VALUE* argv, VALUE self) {
853
+ rb_check_arity(argc, 0, 1);
854
+ return berns_internal_element(rb_utf8_str_new_cstr("tbody"), argv[0]);
855
+ }
856
+
857
+ static VALUE berns_td_element(int argc, VALUE* argv, VALUE self) {
858
+ rb_check_arity(argc, 0, 1);
859
+ return berns_internal_element(rb_utf8_str_new_cstr("td"), argv[0]);
860
+ }
861
+
862
+ static VALUE berns_template_element(int argc, VALUE* argv, VALUE self) {
863
+ rb_check_arity(argc, 0, 1);
864
+ return berns_internal_element(rb_utf8_str_new_cstr("template"), argv[0]);
865
+ }
866
+
867
+ static VALUE berns_textarea_element(int argc, VALUE* argv, VALUE self) {
868
+ rb_check_arity(argc, 0, 1);
869
+ return berns_internal_element(rb_utf8_str_new_cstr("textarea"), argv[0]);
870
+ }
871
+
872
+ static VALUE berns_tfoot_element(int argc, VALUE* argv, VALUE self) {
873
+ rb_check_arity(argc, 0, 1);
874
+ return berns_internal_element(rb_utf8_str_new_cstr("tfoot"), argv[0]);
875
+ }
876
+
877
+ static VALUE berns_th_element(int argc, VALUE* argv, VALUE self) {
878
+ rb_check_arity(argc, 0, 1);
879
+ return berns_internal_element(rb_utf8_str_new_cstr("th"), argv[0]);
880
+ }
881
+
882
+ static VALUE berns_thead_element(int argc, VALUE* argv, VALUE self) {
883
+ rb_check_arity(argc, 0, 1);
884
+ return berns_internal_element(rb_utf8_str_new_cstr("thead"), argv[0]);
885
+ }
886
+
887
+ static VALUE berns_time_element(int argc, VALUE* argv, VALUE self) {
888
+ rb_check_arity(argc, 0, 1);
889
+ return berns_internal_element(rb_utf8_str_new_cstr("time"), argv[0]);
890
+ }
891
+
892
+ static VALUE berns_title_element(int argc, VALUE* argv, VALUE self) {
893
+ rb_check_arity(argc, 0, 1);
894
+ return berns_internal_element(rb_utf8_str_new_cstr("title"), argv[0]);
895
+ }
896
+
897
+ static VALUE berns_tr_element(int argc, VALUE* argv, VALUE self) {
898
+ rb_check_arity(argc, 0, 1);
899
+ return berns_internal_element(rb_utf8_str_new_cstr("tr"), argv[0]);
900
+ }
901
+
902
+ static VALUE berns_u_element(int argc, VALUE* argv, VALUE self) {
903
+ rb_check_arity(argc, 0, 1);
904
+ return berns_internal_element(rb_utf8_str_new_cstr("u"), argv[0]);
905
+ }
906
+
907
+ static VALUE berns_ul_element(int argc, VALUE* argv, VALUE self) {
908
+ rb_check_arity(argc, 0, 1);
909
+ return berns_internal_element(rb_utf8_str_new_cstr("ul"), argv[0]);
910
+ }
911
+
912
+ static VALUE berns_var_element(int argc, VALUE* argv, VALUE self) {
913
+ rb_check_arity(argc, 0, 1);
914
+ return berns_internal_element(rb_utf8_str_new_cstr("var"), argv[0]);
915
+ }
916
+
917
+ static VALUE berns_video_element(int argc, VALUE* argv, VALUE self) {
918
+ rb_check_arity(argc, 0, 1);
919
+ return berns_internal_element(rb_utf8_str_new_cstr("video"), argv[0]);
920
+ }
921
+
922
+ void Init_berns() {
923
+ VALUE Berns = rb_define_module("Berns");
924
+
925
+ rb_define_singleton_method(Berns, "element", berns_element, -1);
926
+ rb_define_singleton_method(Berns, "escape_html", berns_escape_html, 1);
927
+ rb_define_singleton_method(Berns, "to_attribute", berns_to_attribute, 2);
928
+ rb_define_singleton_method(Berns, "to_attributes", berns_to_attributes, 1);
929
+ rb_define_singleton_method(Berns, "void", berns_void_element, -1);
930
+
931
+ /*
932
+ * List of void elements - http://xahlee.info/js/html5_non-closing_tag.html
933
+ *
934
+ * area base br col embed hr img input link menuitem meta param source track wbr
935
+ *
936
+ */
937
+ rb_define_singleton_method(Berns, "area", berns_area_element, -1);
938
+ rb_define_singleton_method(Berns, "base", berns_base_element, -1);
939
+ rb_define_singleton_method(Berns, "br", berns_br_element, -1);
940
+ rb_define_singleton_method(Berns, "col", berns_col_element, -1);
941
+ rb_define_singleton_method(Berns, "embed", berns_embed_element, -1);
942
+ rb_define_singleton_method(Berns, "hr", berns_hr_element, -1);
943
+ rb_define_singleton_method(Berns, "img", berns_img_element, -1);
944
+ rb_define_singleton_method(Berns, "input", berns_input_element, -1);
945
+ rb_define_singleton_method(Berns, "link", berns_link_element, -1);
946
+ rb_define_singleton_method(Berns, "menuitem", berns_menuitem_element, -1);
947
+ rb_define_singleton_method(Berns, "meta", berns_meta_element, -1);
948
+ rb_define_singleton_method(Berns, "param", berns_param_element, -1);
949
+ rb_define_singleton_method(Berns, "source", berns_source_element, -1);
950
+ rb_define_singleton_method(Berns, "track", berns_track_element, -1);
951
+ rb_define_singleton_method(Berns, "wbr", berns_wbr_element, -1);
952
+
953
+ /*
954
+ * List of standard HTML5 elements - https://www.w3schools.com/TAgs/default.asp
955
+ *
956
+ * a abbr address article aside audio b bdi bdo blockquote body button
957
+ * canvas caption cite code colgroup datalist dd del details dfn dialog div
958
+ * dl dt em fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head
959
+ * header html i iframe ins kbd label legend li main map mark menu meter nav
960
+ * noscript object ol optgroup option output p picture pre progress q rp rt
961
+ * ruby s samp script section select small span strong style sub summary
962
+ * table tbody td template textarea tfoot th thead time title tr u ul var
963
+ * video
964
+ *
965
+ */
966
+ rb_define_singleton_method(Berns, "a", berns_a_element, -1);
967
+ rb_define_singleton_method(Berns, "abbr", berns_abbr_element, -1);
968
+ rb_define_singleton_method(Berns, "address", berns_address_element, -1);
969
+ rb_define_singleton_method(Berns, "article", berns_article_element, -1);
970
+ rb_define_singleton_method(Berns, "aside", berns_aside_element, -1);
971
+ rb_define_singleton_method(Berns, "audio", berns_audio_element, -1);
972
+ rb_define_singleton_method(Berns, "b", berns_b_element, -1);
973
+ rb_define_singleton_method(Berns, "bdi", berns_bdi_element, -1);
974
+ rb_define_singleton_method(Berns, "bdo", berns_bdo_element, -1);
975
+ rb_define_singleton_method(Berns, "blockquote", berns_blockquote_element, -1);
976
+ rb_define_singleton_method(Berns, "body", berns_body_element, -1);
977
+ rb_define_singleton_method(Berns, "button", berns_button_element, -1);
978
+ rb_define_singleton_method(Berns, "canvas", berns_canvas_element, -1);
979
+ rb_define_singleton_method(Berns, "caption", berns_caption_element, -1);
980
+ rb_define_singleton_method(Berns, "cite", berns_cite_element, -1);
981
+ rb_define_singleton_method(Berns, "code", berns_code_element, -1);
982
+ rb_define_singleton_method(Berns, "colgroup", berns_colgroup_element, -1);
983
+ rb_define_singleton_method(Berns, "datalist", berns_datalist_element, -1);
984
+ rb_define_singleton_method(Berns, "dd", berns_dd_element, -1);
985
+ rb_define_singleton_method(Berns, "del", berns_del_element, -1);
986
+ rb_define_singleton_method(Berns, "details", berns_details_element, -1);
987
+ rb_define_singleton_method(Berns, "dfn", berns_dfn_element, -1);
988
+ rb_define_singleton_method(Berns, "dialog", berns_dialog_element, -1);
989
+ rb_define_singleton_method(Berns, "div", berns_div_element, -1);
990
+ rb_define_singleton_method(Berns, "dl", berns_dl_element, -1);
991
+ rb_define_singleton_method(Berns, "dt", berns_dt_element, -1);
992
+ rb_define_singleton_method(Berns, "em", berns_em_element, -1);
993
+ rb_define_singleton_method(Berns, "fieldset", berns_fieldset_element, -1);
994
+ rb_define_singleton_method(Berns, "figcaption", berns_figcaption_element, -1);
995
+ rb_define_singleton_method(Berns, "figure", berns_figure_element, -1);
996
+ rb_define_singleton_method(Berns, "footer", berns_footer_element, -1);
997
+ rb_define_singleton_method(Berns, "form", berns_form_element, -1);
998
+ rb_define_singleton_method(Berns, "h1", berns_h1_element, -1);
999
+ rb_define_singleton_method(Berns, "h2", berns_h2_element, -1);
1000
+ rb_define_singleton_method(Berns, "h3", berns_h3_element, -1);
1001
+ rb_define_singleton_method(Berns, "h4", berns_h4_element, -1);
1002
+ rb_define_singleton_method(Berns, "h5", berns_h5_element, -1);
1003
+ rb_define_singleton_method(Berns, "h6", berns_h6_element, -1);
1004
+ rb_define_singleton_method(Berns, "head", berns_head_element, -1);
1005
+ rb_define_singleton_method(Berns, "header", berns_header_element, -1);
1006
+ rb_define_singleton_method(Berns, "html", berns_html_element, -1);
1007
+ rb_define_singleton_method(Berns, "i", berns_i_element, -1);
1008
+ rb_define_singleton_method(Berns, "iframe", berns_iframe_element, -1);
1009
+ rb_define_singleton_method(Berns, "ins", berns_ins_element, -1);
1010
+ rb_define_singleton_method(Berns, "kbd", berns_kbd_element, -1);
1011
+ rb_define_singleton_method(Berns, "label", berns_label_element, -1);
1012
+ rb_define_singleton_method(Berns, "legend", berns_legend_element, -1);
1013
+ rb_define_singleton_method(Berns, "li", berns_li_element, -1);
1014
+ rb_define_singleton_method(Berns, "main", berns_main_element, -1);
1015
+ rb_define_singleton_method(Berns, "map", berns_map_element, -1);
1016
+ rb_define_singleton_method(Berns, "mark", berns_mark_element, -1);
1017
+ rb_define_singleton_method(Berns, "menu", berns_menu_element, -1);
1018
+ rb_define_singleton_method(Berns, "meter", berns_meter_element, -1);
1019
+ rb_define_singleton_method(Berns, "nav", berns_nav_element, -1);
1020
+ rb_define_singleton_method(Berns, "noscript", berns_noscript_element, -1);
1021
+ rb_define_singleton_method(Berns, "object", berns_object_element, -1);
1022
+ rb_define_singleton_method(Berns, "ol", berns_ol_element, -1);
1023
+ rb_define_singleton_method(Berns, "optgroup", berns_optgroup_element, -1);
1024
+ rb_define_singleton_method(Berns, "option", berns_option_element, -1);
1025
+ rb_define_singleton_method(Berns, "output", berns_output_element, -1);
1026
+ rb_define_singleton_method(Berns, "p", berns_p_element, -1);
1027
+ rb_define_singleton_method(Berns, "picture", berns_picture_element, -1);
1028
+ rb_define_singleton_method(Berns, "pre", berns_pre_element, -1);
1029
+ rb_define_singleton_method(Berns, "progress", berns_progress_element, -1);
1030
+ rb_define_singleton_method(Berns, "q", berns_q_element, -1);
1031
+ rb_define_singleton_method(Berns, "rp", berns_rp_element, -1);
1032
+ rb_define_singleton_method(Berns, "rt", berns_rt_element, -1);
1033
+ rb_define_singleton_method(Berns, "ruby", berns_ruby_element, -1);
1034
+ rb_define_singleton_method(Berns, "s", berns_s_element, -1);
1035
+ rb_define_singleton_method(Berns, "samp", berns_samp_element, -1);
1036
+ rb_define_singleton_method(Berns, "script", berns_script_element, -1);
1037
+ rb_define_singleton_method(Berns, "section", berns_section_element, -1);
1038
+ rb_define_singleton_method(Berns, "select", berns_select_element, -1);
1039
+ rb_define_singleton_method(Berns, "small", berns_small_element, -1);
1040
+ rb_define_singleton_method(Berns, "span", berns_span_element, -1);
1041
+ rb_define_singleton_method(Berns, "strong", berns_strong_element, -1);
1042
+ rb_define_singleton_method(Berns, "style", berns_style_element, -1);
1043
+ rb_define_singleton_method(Berns, "sub", berns_sub_element, -1);
1044
+ rb_define_singleton_method(Berns, "summary", berns_summary_element, -1);
1045
+ rb_define_singleton_method(Berns, "table", berns_table_element, -1);
1046
+ rb_define_singleton_method(Berns, "tbody", berns_tbody_element, -1);
1047
+ rb_define_singleton_method(Berns, "td", berns_td_element, -1);
1048
+ rb_define_singleton_method(Berns, "template", berns_template_element, -1);
1049
+ rb_define_singleton_method(Berns, "textarea", berns_textarea_element, -1);
1050
+ rb_define_singleton_method(Berns, "tfoot", berns_tfoot_element, -1);
1051
+ rb_define_singleton_method(Berns, "th", berns_th_element, -1);
1052
+ rb_define_singleton_method(Berns, "thead", berns_thead_element, -1);
1053
+ rb_define_singleton_method(Berns, "time", berns_time_element, -1);
1054
+ rb_define_singleton_method(Berns, "title", berns_title_element, -1);
1055
+ rb_define_singleton_method(Berns, "tr", berns_tr_element, -1);
1056
+ rb_define_singleton_method(Berns, "u", berns_u_element, -1);
1057
+ rb_define_singleton_method(Berns, "ul", berns_ul_element, -1);
1058
+ rb_define_singleton_method(Berns, "var", berns_var_element, -1);
1059
+ rb_define_singleton_method(Berns, "video", berns_video_element, -1);
1060
+ }