haml 6.1.2 → 6.2.3
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
- data/CHANGELOG.md +36 -1
- data/FAQ.md +1 -1
- data/README.md +5 -5
- data/REFERENCE.md +25 -29
- data/Rakefile +3 -37
- data/haml.gemspec +1 -7
- data/lib/haml/attribute_builder.rb +124 -136
- data/lib/haml/attribute_compiler.rb +10 -5
- data/lib/haml/compiler/doctype_compiler.rb +8 -2
- data/lib/haml/rails_template.rb +5 -0
- data/lib/haml/util.rb +5 -4
- data/lib/haml/version.rb +1 -1
- metadata +4 -23
- data/ext/haml/extconf.rb +0 -10
- data/ext/haml/haml.c +0 -537
- data/ext/haml/hescape.c +0 -108
- data/ext/haml/hescape.h +0 -20
data/ext/haml/hescape.c
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
#include <string.h>
|
3
|
-
#include <stdlib.h>
|
4
|
-
#include "hescape.h"
|
5
|
-
|
6
|
-
static const char *ESCAPED_STRING[] = {
|
7
|
-
"",
|
8
|
-
""",
|
9
|
-
"&",
|
10
|
-
"'",
|
11
|
-
"<",
|
12
|
-
">",
|
13
|
-
};
|
14
|
-
|
15
|
-
// This is strlen(ESCAPED_STRING[x]) optimized specially.
|
16
|
-
// Mapping: 1 => 6, 2 => 5, 3 => 5, 4 => 4, 5 => 4
|
17
|
-
#define ESC_LEN(x) ((13 - x) / 2)
|
18
|
-
|
19
|
-
/*
|
20
|
-
* Given ASCII-compatible character, return index of ESCAPED_STRING.
|
21
|
-
*
|
22
|
-
* " (34) => 1 (")
|
23
|
-
* & (38) => 2 (&)
|
24
|
-
* ' (39) => 3 (')
|
25
|
-
* < (60) => 4 (<)
|
26
|
-
* > (62) => 5 (>)
|
27
|
-
*/
|
28
|
-
static const char HTML_ESCAPE_TABLE[] = {
|
29
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
30
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
31
|
-
0, 0, 1, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0,
|
32
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 5, 0,
|
33
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
34
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
35
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
36
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
37
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
38
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
39
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
40
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
41
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
42
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
43
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
44
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
45
|
-
};
|
46
|
-
|
47
|
-
static char*
|
48
|
-
ensure_allocated(char *buf, size_t size, size_t *asize)
|
49
|
-
{
|
50
|
-
size_t new_size;
|
51
|
-
|
52
|
-
if (size < *asize)
|
53
|
-
return buf;
|
54
|
-
|
55
|
-
if (*asize == 0) {
|
56
|
-
new_size = size;
|
57
|
-
} else {
|
58
|
-
new_size = *asize;
|
59
|
-
}
|
60
|
-
|
61
|
-
// Increase buffer size by 1.5x if realloced multiple times.
|
62
|
-
while (new_size < size)
|
63
|
-
new_size = (new_size << 1) - (new_size >> 1);
|
64
|
-
|
65
|
-
// Round allocation up to multiple of 8.
|
66
|
-
new_size = (new_size + 7) & ~7;
|
67
|
-
|
68
|
-
*asize = new_size;
|
69
|
-
return realloc(buf, new_size);
|
70
|
-
}
|
71
|
-
|
72
|
-
size_t
|
73
|
-
hesc_escape_html(char **dest, const char *buf, size_t size)
|
74
|
-
{
|
75
|
-
size_t asize = 0, esc_i = 0, esize = 0, i = 0, rbuf_end = 0;
|
76
|
-
const char *esc;
|
77
|
-
char *rbuf = NULL;
|
78
|
-
|
79
|
-
while (i < size) {
|
80
|
-
// Loop here to skip non-escaped characters fast.
|
81
|
-
while (i < size && (esc_i = HTML_ESCAPE_TABLE[(unsigned char)buf[i]]) == 0)
|
82
|
-
i++;
|
83
|
-
|
84
|
-
if (i < size && esc_i) {
|
85
|
-
esc = ESCAPED_STRING[esc_i];
|
86
|
-
rbuf = ensure_allocated(rbuf, sizeof(char) * (size + esize + ESC_LEN(esc_i) + 1), &asize);
|
87
|
-
|
88
|
-
// Copy pending characters and escaped string.
|
89
|
-
memmove(rbuf + rbuf_end, buf + (rbuf_end - esize), i - (rbuf_end - esize));
|
90
|
-
memmove(rbuf + i + esize, esc, ESC_LEN(esc_i));
|
91
|
-
rbuf_end = i + esize + ESC_LEN(esc_i);
|
92
|
-
esize += ESC_LEN(esc_i) - 1;
|
93
|
-
}
|
94
|
-
i++;
|
95
|
-
}
|
96
|
-
|
97
|
-
if (rbuf_end == 0) {
|
98
|
-
// Return given buf and size if there are no escaped characters.
|
99
|
-
*dest = (char *)buf;
|
100
|
-
return size;
|
101
|
-
} else {
|
102
|
-
// Copy pending characters including NULL character.
|
103
|
-
memmove(rbuf + rbuf_end, buf + (rbuf_end - esize), (size + 1) - (rbuf_end - esize));
|
104
|
-
|
105
|
-
*dest = rbuf;
|
106
|
-
return size + esize;
|
107
|
-
}
|
108
|
-
}
|
data/ext/haml/hescape.h
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#ifndef HESCAPE_H
|
2
|
-
#define HESCAPE_H
|
3
|
-
|
4
|
-
#include <sys/types.h>
|
5
|
-
|
6
|
-
/*
|
7
|
-
* Replace characters according to the following rules.
|
8
|
-
* Note that this function can handle only ASCII-compatible string.
|
9
|
-
*
|
10
|
-
* " => "
|
11
|
-
* & => &
|
12
|
-
* ' => '
|
13
|
-
* < => <
|
14
|
-
* > => >
|
15
|
-
*
|
16
|
-
* @return size of dest. If it's larger than len, dest is required to be freed.
|
17
|
-
*/
|
18
|
-
extern size_t hesc_escape_html(char **dest, const char *src, size_t size);
|
19
|
-
|
20
|
-
#endif
|