A Markdown shard for the Crystal programming language
Révision | 1ec665f4fddae9acb7f979e2849803b595d108d8 (tree) |
---|---|
l'heure | 2023-04-07 11:07:45 |
Auteur | supercell <stigma@disr...> |
Commiter | supercell |
Optimize TableSyntax
@@ -4,7 +4,20 @@ head | cells | ||
4 | 4 | body | cells |
5 | 5 | |
6 | 6 | <<< |
7 | -<table><thead><tr><th>head</th><th>cells</th></tr></thead><tbody><tr><td>body</td><td>cells</td></tr></tbody></table> | |
7 | +<table> | |
8 | +<thead> | |
9 | +<tr> | |
10 | +<th>head</th> | |
11 | +<th>cells</th> | |
12 | +</tr> | |
13 | +</thead> | |
14 | +<tbody> | |
15 | +<tr> | |
16 | +<td>body</td> | |
17 | +<td>cells</td> | |
18 | +</tr> | |
19 | +</tbody> | |
20 | +</table> | |
8 | 21 | >>> multiple rows |
9 | 22 | head | cells |
10 | 23 | -----|------ |
@@ -12,40 +25,124 @@ body | cells | ||
12 | 25 | more | cells |
13 | 26 | |
14 | 27 | <<< |
15 | -<table><thead><tr><th>head</th><th>cells</th></tr></thead><tbody><tr><td>body</td><td>cells</td></tr><tr><td>more</td><td>cells</td></tr></tbody></table> | |
28 | +<table> | |
29 | +<thead> | |
30 | +<tr> | |
31 | +<th>head</th> | |
32 | +<th>cells</th> | |
33 | +</tr> | |
34 | +</thead> | |
35 | +<tbody> | |
36 | +<tr> | |
37 | +<td>body</td> | |
38 | +<td>cells</td> | |
39 | +</tr> | |
40 | +<tr> | |
41 | +<td>more</td> | |
42 | +<td>cells</td> | |
43 | +</tr> | |
44 | +</tbody> | |
45 | +</table> | |
16 | 46 | >>> rows wrapped in pipes |
17 | 47 | | head | cells | |
18 | 48 | |------|-------| |
19 | 49 | | body | cells | |
20 | 50 | |
21 | 51 | <<< |
22 | -<table><thead><tr><th>head</th><th>cells</th></tr></thead><tbody><tr><td>body</td><td>cells</td></tr></tbody></table> | |
52 | +<table> | |
53 | +<thead> | |
54 | +<tr> | |
55 | +<th>head</th> | |
56 | +<th>cells</th> | |
57 | +</tr> | |
58 | +</thead> | |
59 | +<tbody> | |
60 | +<tr> | |
61 | +<td>body</td> | |
62 | +<td>cells</td> | |
63 | +</tr> | |
64 | +</tbody> | |
65 | +</table> | |
23 | 66 | >>> rows wrapped in pipes, whitespace alignment row |
24 | 67 | | head | cells | |
25 | 68 | | -- | --- | |
26 | 69 | | body | cells | |
27 | 70 | |
28 | 71 | <<< |
29 | -<table><thead><tr><th>head</th><th>cells</th></tr></thead><tbody><tr><td>body</td><td>cells</td></tr></tbody></table> | |
72 | +<table> | |
73 | +<thead> | |
74 | +<tr> | |
75 | +<th>head</th> | |
76 | +<th>cells</th> | |
77 | +</tr> | |
78 | +</thead> | |
79 | +<tbody> | |
80 | +<tr> | |
81 | +<td>body</td> | |
82 | +<td>cells</td> | |
83 | +</tr> | |
84 | +</tbody> | |
85 | +</table> | |
30 | 86 | >>> rows wrapped in pipes, tabs in whitespace |
31 | 87 | | head | cells | |
32 | 88 | | -- | --- | |
33 | 89 | | body | cells | |
34 | 90 | |
35 | 91 | <<< |
36 | -<table><thead><tr><th>head</th><th>cells</th></tr></thead><tbody><tr><td>body</td><td>cells</td></tr></tbody></table> | |
92 | +<table> | |
93 | +<thead> | |
94 | +<tr> | |
95 | +<th>head</th> | |
96 | +<th>cells</th> | |
97 | +</tr> | |
98 | +</thead> | |
99 | +<tbody> | |
100 | +<tr> | |
101 | +<td>body</td> | |
102 | +<td>cells</td> | |
103 | +</tr> | |
104 | +</tbody> | |
105 | +</table> | |
37 | 106 | >>> cells with inline syntax |
38 | 107 | head `code` | _cells_ |
39 | 108 | ------------|-------- |
40 | 109 | *text* | <span>text</span> |
41 | 110 | <<< |
42 | -<table><thead><tr><th>head <code>code</code></th><th><em>cells</em></th></tr></thead><tbody><tr><td><em>text</em></td><td><span>text</span></td></tr></tbody></table> | |
111 | +<table> | |
112 | +<thead> | |
113 | +<tr> | |
114 | +<th>head <code>code</code></th> | |
115 | +<th><em>cells</em></th> | |
116 | +</tr> | |
117 | +</thead> | |
118 | +<tbody> | |
119 | +<tr> | |
120 | +<td><em>text</em></td> | |
121 | +<td><span>text</span></td> | |
122 | +</tr> | |
123 | +</tbody> | |
124 | +</table> | |
43 | 125 | >>> cells are parsed before inline syntax |
44 | 126 | header | _foo | bar_ |
45 | 127 | -------|------------|--- |
46 | 128 | text | text |
47 | 129 | <<< |
48 | -<table><thead><tr><th>header</th><th>_foo</th><th>bar_</th></tr></thead><tbody><tr><td>text</td><td>text</td><td /></tr></tbody></table> | |
130 | +<table> | |
131 | +<thead> | |
132 | +<tr> | |
133 | +<th>header</th> | |
134 | +<th>_foo</th> | |
135 | +<th>bar_</th> | |
136 | +</tr> | |
137 | +</thead> | |
138 | +<tbody> | |
139 | +<tr> | |
140 | +<td>text</td> | |
141 | +<td>text</td> | |
142 | +<td></td> | |
143 | +</tr> | |
144 | +</tbody> | |
145 | +</table> | |
49 | 146 | >>> cells contain reference links |
50 | 147 | header | header |
51 | 148 | -------|-------- |
@@ -53,20 +150,64 @@ text | [link][here] | ||
53 | 150 | |
54 | 151 | [here]: http://url |
55 | 152 | <<< |
56 | -<table><thead><tr><th>header</th><th>header</th></tr></thead><tbody><tr><td>text</td><td><a href="http://url">link</a></td></tr></tbody></table> | |
153 | +<table> | |
154 | +<thead> | |
155 | +<tr> | |
156 | +<th>header</th> | |
157 | +<th>header</th> | |
158 | +</tr> | |
159 | +</thead> | |
160 | +<tbody> | |
161 | +<tr> | |
162 | +<td>text</td> | |
163 | +<td><a href="http://url">link</a></td> | |
164 | +</tr> | |
165 | +</tbody> | |
166 | +</table> | |
57 | 167 | >>> one column tables |
58 | 168 | head |
59 | 169 | -----| |
60 | 170 | body |
61 | 171 | <<< |
62 | -<table><thead><tr><th>head</th></tr></thead><tbody><tr><td>body</td></tr></tbody></table> | |
172 | +<table> | |
173 | +<thead> | |
174 | +<tr> | |
175 | +<th>head</th> | |
176 | +</tr> | |
177 | +</thead> | |
178 | +<tbody> | |
179 | +<tr> | |
180 | +<td>body</td> | |
181 | +</tr> | |
182 | +</tbody> | |
183 | +</table> | |
63 | 184 | >>> varying cells per row |
64 | 185 | head | foo | bar |
65 | 186 | -----|-----|----- |
66 | 187 | body |
67 | 188 | row with | two cells |
68 | 189 | <<< |
69 | -<table><thead><tr><th>head</th><th>foo</th><th>bar</th></tr></thead><tbody><tr><td>body</td><td /><td /></tr><tr><td>row with</td><td>two cells</td><td /></tr></tbody></table> | |
190 | +<table> | |
191 | +<thead> | |
192 | +<tr> | |
193 | +<th>head</th> | |
194 | +<th>foo</th> | |
195 | +<th>bar</th> | |
196 | +</tr> | |
197 | +</thead> | |
198 | +<tbody> | |
199 | +<tr> | |
200 | +<td>body</td> | |
201 | +<td></td> | |
202 | +<td></td> | |
203 | +</tr> | |
204 | +<tr> | |
205 | +<td>row with</td> | |
206 | +<td>two cells</td> | |
207 | +<td></td> | |
208 | +</tr> | |
209 | +</tbody> | |
210 | +</table> | |
70 | 211 | >>> left, center, and right alignment |
71 | 212 | head | cells | here |
72 | 213 | :----|:-----:|----: |
@@ -74,7 +215,27 @@ body | cells | here | ||
74 | 215 | too | many | cells | here |
75 | 216 | |
76 | 217 | <<< |
77 | -<table><thead><tr><th style="text-align: left;">head</th><th style="text-align: center;">cells</th><th style="text-align: right;">here</th></tr></thead><tbody><tr><td style="text-align: left;">body</td><td style="text-align: center;">cells</td><td style="text-align: right;">here</td></tr><tr><td style="text-align: left;">too</td><td style="text-align: center;">many</td><td style="text-align: right;">cells</td></tr></tbody></table> | |
218 | +<table> | |
219 | +<thead> | |
220 | +<tr> | |
221 | +<th align="left">head</th> | |
222 | +<th align="center">cells</th> | |
223 | +<th align="right">here</th> | |
224 | +</tr> | |
225 | +</thead> | |
226 | +<tbody> | |
227 | +<tr> | |
228 | +<td align="left">body</td> | |
229 | +<td align="center">cells</td> | |
230 | +<td align="right">here</td> | |
231 | +</tr> | |
232 | +<tr> | |
233 | +<td align="left">too</td> | |
234 | +<td align="center">many</td> | |
235 | +<td align="right">cells</td> | |
236 | +</tr> | |
237 | +</tbody> | |
238 | +</table> | |
78 | 239 | >>> left, center, and right alignment, with whitespace |
79 | 240 | head | cells | here |
80 | 241 | :-- | :---: | ---: |
@@ -82,7 +243,27 @@ body | cells | here | ||
82 | 243 | too | many | cells | here |
83 | 244 | |
84 | 245 | <<< |
85 | -<table><thead><tr><th style="text-align: left;">head</th><th style="text-align: center;">cells</th><th style="text-align: right;">here</th></tr></thead><tbody><tr><td style="text-align: left;">body</td><td style="text-align: center;">cells</td><td style="text-align: right;">here</td></tr><tr><td style="text-align: left;">too</td><td style="text-align: center;">many</td><td style="text-align: right;">cells</td></tr></tbody></table> | |
246 | +<table> | |
247 | +<thead> | |
248 | +<tr> | |
249 | +<th align="left">head</th> | |
250 | +<th align="center">cells</th> | |
251 | +<th align="right">here</th> | |
252 | +</tr> | |
253 | +</thead> | |
254 | +<tbody> | |
255 | +<tr> | |
256 | +<td align="left">body</td> | |
257 | +<td align="center">cells</td> | |
258 | +<td align="right">here</td> | |
259 | +</tr> | |
260 | +<tr> | |
261 | +<td align="left">too</td> | |
262 | +<td align="center">many</td> | |
263 | +<td align="right">cells</td> | |
264 | +</tr> | |
265 | +</tbody> | |
266 | +</table> | |
86 | 267 | >>> escape pipe |
87 | 268 | | Name | Character | |
88 | 269 | | --- | --- | |
@@ -90,17 +271,60 @@ too | many | cells | here | ||
90 | 271 | | Pipe | \| | |
91 | 272 | |
92 | 273 | <<< |
93 | -<table><thead><tr><th>Name</th><th>Character</th></tr></thead><tbody><tr><td>Backtick</td><td>`</td></tr><tr><td>Pipe</td><td>|</td></tr></tbody></table> | |
274 | +<table> | |
275 | +<thead> | |
276 | +<tr> | |
277 | +<th>Name</th> | |
278 | +<th>Character</th> | |
279 | +</tr> | |
280 | +</thead> | |
281 | +<tbody> | |
282 | +<tr> | |
283 | +<td>Backtick</td> | |
284 | +<td>`</td> | |
285 | +</tr> | |
286 | +<tr> | |
287 | +<td>Pipe</td> | |
288 | +<td>|</td> | |
289 | +</tr> | |
290 | +</tbody> | |
291 | +</table> | |
94 | 292 | >>> escape pipe, preserve trailing whitespace |
95 | 293 | | Name | Character | |
96 | 294 | | --- | --- | |
97 | 295 | | Pipe | \| abcdef | |
98 | 296 | |
99 | 297 | <<< |
100 | -<table><thead><tr><th>Name</th><th>Character</th></tr></thead><tbody><tr><td>Pipe</td><td>| abcdef</td></tr></tbody></table> | |
298 | +<table> | |
299 | +<thead> | |
300 | +<tr> | |
301 | +<th>Name</th> | |
302 | +<th>Character</th> | |
303 | +</tr> | |
304 | +</thead> | |
305 | +<tbody> | |
306 | +<tr> | |
307 | +<td>Pipe</td> | |
308 | +<td>| abcdef</td> | |
309 | +</tr> | |
310 | +</tbody> | |
311 | +</table> | |
101 | 312 | >>> trailing whitespace after final pipe |
102 | 313 | | Name | Character | |
103 | 314 | | --- | --- | |
104 | 315 | | Pipe | abcdef | |
105 | 316 | <<< |
106 | -<table><thead><tr><th>Name</th><th>Character</th></tr></thead><tbody><tr><td>Pipe</td><td>abcdef</td></tr></tbody></table> | |
317 | +<table> | |
318 | +<thead> | |
319 | +<tr> | |
320 | +<th>Name</th> | |
321 | +<th>Character</th> | |
322 | +</tr> | |
323 | +</thead> | |
324 | +<tbody> | |
325 | +<tr> | |
326 | +<td>Pipe</td> | |
327 | +<td>abcdef</td> | |
328 | +</tr> | |
329 | +</tbody> | |
330 | +</table> |
@@ -3,27 +3,80 @@ | ||
3 | 3 | | --- | --- | |
4 | 4 | | baz | bim | |
5 | 5 | <<< |
6 | -<table><thead><tr><th>foo</th><th>bar</th></tr></thead><tbody><tr><td>baz</td><td>bim</td></tr></tbody></table> | |
6 | +<table> | |
7 | +<thead> | |
8 | +<tr> | |
9 | +<th>foo</th> | |
10 | +<th>bar</th> | |
11 | +</tr> | |
12 | +</thead> | |
13 | +<tbody> | |
14 | +<tr> | |
15 | +<td>baz</td> | |
16 | +<td>bim</td> | |
17 | +</tr> | |
18 | +</tbody> | |
19 | +</table> | |
7 | 20 | >>> Tables (extension) - 199 |
8 | 21 | | abc | defghi | |
9 | 22 | :-: | -----------: |
10 | 23 | bar | baz |
11 | 24 | <<< |
12 | -<table><thead><tr><th style="text-align: center;">abc</th><th style="text-align: right;">defghi</th></tr></thead><tbody><tr><td style="text-align: center;">bar</td><td style="text-align: right;">baz</td></tr></tbody></table> | |
25 | +<table> | |
26 | +<thead> | |
27 | +<tr> | |
28 | +<th align="center">abc</th> | |
29 | +<th align="right">defghi</th> | |
30 | +</tr> | |
31 | +</thead> | |
32 | +<tbody> | |
33 | +<tr> | |
34 | +<td align="center">bar</td> | |
35 | +<td align="right">baz</td> | |
36 | +</tr> | |
37 | +</tbody> | |
38 | +</table> | |
13 | 39 | >>> Tables (extension) - 200 |
14 | 40 | | f\|oo | |
15 | 41 | | ------ | |
16 | 42 | | b `\|` az | |
17 | 43 | | b **\|** im | |
18 | 44 | <<< |
19 | -<table><thead><tr><th>f|oo</th></tr></thead><tbody><tr><td>b <code>|</code> az</td></tr><tr><td>b <strong>|</strong> im</td></tr></tbody></table> | |
45 | +<table> | |
46 | +<thead> | |
47 | +<tr> | |
48 | +<th>f|oo</th> | |
49 | +</tr> | |
50 | +</thead> | |
51 | +<tbody> | |
52 | +<tr> | |
53 | +<td>b <code>|</code> az</td> | |
54 | +</tr> | |
55 | +<tr> | |
56 | +<td>b <strong>|</strong> im</td> | |
57 | +</tr> | |
58 | +</tbody> | |
59 | +</table> | |
20 | 60 | >>> Tables (extension) - 201 |
21 | 61 | | abc | def | |
22 | 62 | | --- | --- | |
23 | 63 | | bar | baz | |
24 | 64 | > bar |
25 | 65 | <<< |
26 | -<table><thead><tr><th>abc</th><th>def</th></tr></thead><tbody><tr><td>bar</td><td>baz</td></tr></tbody></table> | |
66 | +<table> | |
67 | +<thead> | |
68 | +<tr> | |
69 | +<th>abc</th> | |
70 | +<th>def</th> | |
71 | +</tr> | |
72 | +</thead> | |
73 | +<tbody> | |
74 | +<tr> | |
75 | +<td>bar</td> | |
76 | +<td>baz</td> | |
77 | +</tr> | |
78 | +</tbody> | |
79 | +</table> | |
27 | 80 | <blockquote> |
28 | 81 | <p>bar</p> |
29 | 82 | </blockquote> |
@@ -35,14 +88,32 @@ bar | ||
35 | 88 | |
36 | 89 | bar |
37 | 90 | <<< |
38 | -<table><thead><tr><th>abc</th><th>def</th></tr></thead><tbody><tr><td>bar</td><td>baz</td></tr><tr><td>bar</td><td /></tr></tbody></table> | |
91 | +<table> | |
92 | +<thead> | |
93 | +<tr> | |
94 | +<th>abc</th> | |
95 | +<th>def</th> | |
96 | +</tr> | |
97 | +</thead> | |
98 | +<tbody> | |
99 | +<tr> | |
100 | +<td>bar</td> | |
101 | +<td>baz</td> | |
102 | +</tr> | |
103 | +<tr> | |
104 | +<td>bar</td> | |
105 | +<td></td> | |
106 | +</tr> | |
107 | +</tbody> | |
108 | +</table> | |
39 | 109 | <p>bar</p> |
40 | 110 | >>> Tables (extension) - 203 |
41 | 111 | | abc | def | |
42 | 112 | | --- | |
43 | 113 | | bar | |
44 | 114 | <<< |
45 | -<p>| --- | | |
115 | +<p>| abc | def | | |
116 | +| --- | | |
46 | 117 | | bar |</p> |
47 | 118 | >>> Tables (extension) - 204 |
48 | 119 | | abc | def | |
@@ -50,9 +121,33 @@ bar | ||
50 | 121 | | bar | |
51 | 122 | | bar | baz | boo | |
52 | 123 | <<< |
53 | -<table><thead><tr><th>abc</th><th>def</th></tr></thead><tbody><tr><td>bar</td><td /></tr><tr><td>bar</td><td>baz</td></tr></tbody></table> | |
124 | +<table> | |
125 | +<thead> | |
126 | +<tr> | |
127 | +<th>abc</th> | |
128 | +<th>def</th> | |
129 | +</tr> | |
130 | +</thead> | |
131 | +<tbody> | |
132 | +<tr> | |
133 | +<td>bar</td> | |
134 | +<td></td> | |
135 | +</tr> | |
136 | +<tr> | |
137 | +<td>bar</td> | |
138 | +<td>baz</td> | |
139 | +</tr> | |
140 | +</tbody> | |
141 | +</table> | |
54 | 142 | >>> Tables (extension) - 205 |
55 | 143 | | abc | def | |
56 | 144 | | --- | --- | |
57 | 145 | <<< |
58 | -<table><thead><tr><th>abc</th><th>def</th></tr></thead></table> | |
146 | +<table> | |
147 | +<thead> | |
148 | +<tr> | |
149 | +<th>abc</th> | |
150 | +<th>def</th> | |
151 | +</tr> | |
152 | +</thead> | |
153 | +</table> |
@@ -88,6 +88,10 @@ module Luce | ||
88 | 88 | @pos += 1 |
89 | 89 | end |
90 | 90 | |
91 | + def retreat : Nil | |
92 | + @pos -= 1 | |
93 | + end | |
94 | + | |
91 | 95 | def done? : Bool |
92 | 96 | @pos >= @lines.size |
93 | 97 | end |
@@ -106,11 +110,23 @@ module Luce | ||
106 | 110 | |
107 | 111 | def parse_lines : Array(Node) |
108 | 112 | blocks = [] of Node |
113 | + | |
114 | + # If the @pos does not change before and after `parse()`, never try to | |
115 | + # parse the line at @pos with the same syntax again. | |
116 | + # For example, the `TableSyntax` might not advance the @pos in `parse` | |
117 | + # method, because the header row does not match the delimiter row in the | |
118 | + # number of cells, which makes the table like structure not be recognized. | |
119 | + never_match : BlockSyntax? = nil | |
120 | + | |
109 | 121 | until done? |
110 | 122 | block_syntaxes.each do |syntax| |
123 | + next if never_match == syntax | |
124 | + | |
111 | 125 | if syntax.can_parse? self |
126 | + position_before = @pos | |
112 | 127 | block = syntax.parse self |
113 | 128 | blocks << block unless block.nil? |
129 | + never_match = @pos != position_before ? nil : syntax | |
114 | 130 | break |
115 | 131 | end |
116 | 132 | end |
@@ -28,7 +28,10 @@ module Luce | ||
28 | 28 | alignments = parse_alignments(parser.next.not_nil!) |
29 | 29 | column_count = alignments.size |
30 | 30 | head_row = parse_row(parser, alignments, "th") |
31 | - return nil if head_row.children.not_nil!.size != column_count | |
31 | + if head_row.children.not_nil!.size != column_count | |
32 | + parser.retreat | |
33 | + return nil | |
34 | + end | |
32 | 35 | |
33 | 36 | head = Element.new("thead", [head_row.as Node]) |
34 | 37 |
@@ -42,7 +45,7 @@ module Luce | ||
42 | 45 | if !children.nil? |
43 | 46 | while children.size < column_count |
44 | 47 | # Insert synthetic empty cells. |
45 | - children << Element.empty("td").as Node | |
48 | + children << Element.new("td", [] of Node) | |
46 | 49 | end |
47 | 50 | while children.size > column_count |
48 | 51 | children.pop |
@@ -62,29 +65,37 @@ module Luce | ||
62 | 65 | end |
63 | 66 | |
64 | 67 | private def parse_alignments(line : String) : Array(String?) |
65 | - start_index = walk_past_opening_pipe(line) | |
66 | - | |
67 | - end_index = line.size - 1 | |
68 | - while end_index > 0 | |
69 | - ch = line.codepoint_at(end_index) | |
70 | - if ch == Charcode::PIPE | |
71 | - end_index -= 1 | |
72 | - break | |
68 | + columns = [] of String? | |
69 | + # Set the value to `true` when hitting a non whitespace character other | |
70 | + # than the first pipe character. | |
71 | + started = false | |
72 | + hit_dash = false | |
73 | + alignment : String? = nil | |
74 | + | |
75 | + line.each_codepoint do |char| | |
76 | + next if char == Charcode::SPACE || char == Charcode::TAB || (!started && char == Charcode::PIPE) | |
77 | + started = true | |
78 | + | |
79 | + if char == Charcode::COLON | |
80 | + if hit_dash | |
81 | + alignment = alignment == "left" ? "center" : "right" | |
82 | + else | |
83 | + alignment = "left" | |
84 | + end | |
73 | 85 | end |
74 | - if ch != Charcode::SPACE && ch != Charcode::TAB | |
75 | - break | |
86 | + | |
87 | + if char == Charcode::PIPE | |
88 | + columns << alignment | |
89 | + hit_dash = false | |
90 | + alignment = nil | |
91 | + else | |
92 | + hit_dash = true | |
76 | 93 | end |
77 | - end_index -= 1 | |
78 | 94 | end |
79 | 95 | |
80 | - # Optimization: We walk *line* too many times. One lap should do it. | |
81 | - line[start_index..end_index].split('|').map do |column| | |
82 | - column = column.strip | |
83 | - next "center" if column.starts_with?(":") && column.ends_with?(":") | |
84 | - next "left" if column.starts_with?(":") | |
85 | - next "right" if column.ends_with?(":") | |
86 | - nil | |
87 | - end | |
96 | + columns << alignment if hit_dash | |
97 | + | |
98 | + columns | |
88 | 99 | end |
89 | 100 | |
90 | 101 | # Parses a table row at the current line into a table row element, with |
@@ -152,7 +163,7 @@ module Luce | ||
152 | 163 | next |
153 | 164 | end |
154 | 165 | |
155 | - (row[i].as Element).attributes["style"] = "text-align: #{alignments[i]};" | |
166 | + (row[i].as Element).attributes["align"] = "#{alignments[i]}" | |
156 | 167 | i += 1 |
157 | 168 | end |
158 | 169 |
@@ -36,6 +36,11 @@ module Luce | ||
36 | 36 | "nav", |
37 | 37 | "section", |
38 | 38 | "table", |
39 | + "thead", | |
40 | + "tbody", | |
41 | + "th", | |
42 | + "tr", | |
43 | + "td", | |
39 | 44 | ] |
40 | 45 | |
41 | 46 | protected def self.block_tags : Array(String) |
@@ -219,14 +219,14 @@ | ||
219 | 219 | "197": "strict" |
220 | 220 | }, |
221 | 221 | "Tables (extension)": { |
222 | - "198": "fail", | |
223 | - "199": "fail", | |
224 | - "200": "fail", | |
225 | - "201": "fail", | |
226 | - "202": "fail", | |
227 | - "203": "loose", | |
228 | - "204": "fail", | |
229 | - "205": "fail" | |
222 | + "198": "strict", | |
223 | + "199": "strict", | |
224 | + "200": "strict", | |
225 | + "201": "strict", | |
226 | + "202": "strict", | |
227 | + "203": "strict", | |
228 | + "204": "strict", | |
229 | + "205": "strict" | |
230 | 230 | }, |
231 | 231 | "Block quotes": { |
232 | 232 | "206": "strict", |
@@ -9,7 +9,7 @@ | ||
9 | 9 | 21 of 28 - 75.0% Link reference definitions |
10 | 10 | 8 of 8 - 100.0% Paragraphs |
11 | 11 | 1 of 1 - 100.0% Blank lines |
12 | - 1 of 8 - 12.5% Tables (extension) | |
12 | + 8 of 8 - 100.0% Tables (extension) | |
13 | 13 | 23 of 25 - 92.0% Block quotes |
14 | 14 | 45 of 48 - 93.8% List items |
15 | 15 | 19 of 26 - 73.1% Lists |
@@ -28,5 +28,5 @@ | ||
28 | 28 | 15 of 15 - 100.0% Hard line breaks |
29 | 29 | 2 of 2 - 100.0% Soft line breaks |
30 | 30 | 3 of 3 - 100.0% Textual content |
31 | - 614 of 671 - 91.5% TOTAL | |
32 | - 561 of 614 - 91.4% TOTAL Strict | |
31 | + 621 of 671 - 92.5% TOTAL | |
32 | + 569 of 621 - 91.6% TOTAL Strict |