Skip to content

Commit 83b5b3b

Browse files
committed
🐛 [HTML] Sort properties and style keys
1 parent bf603ed commit 83b5b3b

18 files changed

+188
-182
lines changed

src/backends/html/private.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ function _html__create_style(style::Vector{HtmlPair})
107107
# Create the style string.
108108
style_str = " style = \""
109109

110+
# Make sure the style is sorted by key.
111+
sort!(style)
112+
110113
@inbounds for i in eachindex(style)
111114
key, value = style[i]
112115

@@ -144,7 +147,10 @@ function _html__open_tag(
144147
# Compile the text with the properties.
145148
properties_str = ""
146149

150+
# Make sure the properties are sorted by key.
147151
if !isnothing(properties)
152+
sort!(properties)
153+
148154
for (k, v) in properties
149155
if !isempty(v)
150156
v_str = _html__escape_str(v)

test/backends/html/alignment.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
<table>
1313
<thead>
1414
<tr class = "columnLabelRow">
15-
<th style = "text-align: center; font-weight: bold;">Col. 1</th>
16-
<th style = "text-align: center; font-weight: bold;">Col. 2</th>
17-
<th style = "text-align: center; font-weight: bold;">Col. 3</th>
18-
<th style = "text-align: center; font-weight: bold;">Col. 4</th>
19-
<th style = "text-align: center; font-weight: bold;">Col. 5</th>
15+
<th style = "font-weight: bold; text-align: center;">Col. 1</th>
16+
<th style = "font-weight: bold; text-align: center;">Col. 2</th>
17+
<th style = "font-weight: bold; text-align: center;">Col. 3</th>
18+
<th style = "font-weight: bold; text-align: center;">Col. 4</th>
19+
<th style = "font-weight: bold; text-align: center;">Col. 5</th>
2020
</tr>
2121
</thead>
2222
<tbody>
@@ -135,11 +135,11 @@
135135
<table>
136136
<thead>
137137
<tr class = "columnLabelRow">
138-
<th style = "text-align: left; font-weight: bold;">Col. 1</th>
139-
<th style = "text-align: center; font-weight: bold;">Col. 2</th>
140-
<th style = "text-align: right; font-weight: bold;">Col. 3</th>
141-
<th style = "text-align: left; font-weight: bold;">Col. 4</th>
142-
<th style = "text-align: center; font-weight: bold;">Col. 5</th>
138+
<th style = "font-weight: bold; text-align: left;">Col. 1</th>
139+
<th style = "font-weight: bold; text-align: center;">Col. 2</th>
140+
<th style = "font-weight: bold; text-align: right;">Col. 3</th>
141+
<th style = "font-weight: bold; text-align: left;">Col. 4</th>
142+
<th style = "font-weight: bold; text-align: center;">Col. 5</th>
143143
</tr>
144144
</thead>
145145
<tbody>
@@ -196,11 +196,11 @@
196196
<table>
197197
<thead>
198198
<tr class = "columnLabelRow">
199-
<th style = "text-align: left; font-weight: bold;">Col. 1</th>
200-
<th style = "text-align: center; font-weight: bold;">Col. 2</th>
201-
<th style = "text-align: right; font-weight: bold;">Col. 3</th>
199+
<th style = "font-weight: bold; text-align: left;">Col. 1</th>
200+
<th style = "font-weight: bold; text-align: center;">Col. 2</th>
201+
<th style = "font-weight: bold; text-align: right;">Col. 3</th>
202202
<th style = "font-weight: bold;">Col. 4</th>
203-
<th style = "text-align: right; font-weight: bold;">Col. 5</th>
203+
<th style = "font-weight: bold; text-align: right;">Col. 5</th>
204204
</tr>
205205
</thead>
206206
<tbody>

test/backends/html/cell_titles.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
<table>
1515
<thead>
1616
<tr class = "columnLabelRow">
17-
<th title = "1" style = "text-align: right; font-weight: bold;">(1, 1)</th>
18-
<th title = "2" style = "text-align: right; font-weight: bold;">(1, 2)</th>
19-
<th title = "3" style = "text-align: right; font-weight: bold;">(1, 3)</th>
20-
<th title = "4" style = "text-align: right; font-weight: bold;">(1, 4)</th>
17+
<th title = "1" style = "font-weight: bold; text-align: right;">(1, 1)</th>
18+
<th title = "2" style = "font-weight: bold; text-align: right;">(1, 2)</th>
19+
<th title = "3" style = "font-weight: bold; text-align: right;">(1, 3)</th>
20+
<th title = "4" style = "font-weight: bold; text-align: right;">(1, 4)</th>
2121
</tr>
2222
<tr class = "columnLabelRow">
2323
<th style = "text-align: right;">(2, 1)</th>

test/backends/html/circular_reference.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
<table>
2020
<thead>
2121
<tr class = "columnLabelRow">
22-
<th style = "text-align: right; font-weight: bold;">A1</th>
23-
<th style = "text-align: right; font-weight: bold;">A2</th>
24-
<th style = "text-align: right; font-weight: bold;">A3</th>
25-
<th style = "text-align: right; font-weight: bold;">A4</th>
22+
<th style = "font-weight: bold; text-align: right;">A1</th>
23+
<th style = "font-weight: bold; text-align: right;">A2</th>
24+
<th style = "font-weight: bold; text-align: right;">A3</th>
25+
<th style = "font-weight: bold; text-align: right;">A4</th>
2626
</tr>
2727
</thead>
2828
<tbody>

test/backends/html/column_width.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@
1111
<table>
1212
<thead>
1313
<tr class = "columnLabelRow">
14-
<th style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold;">Col. 1</th>
15-
<th style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold;">Col. 2</th>
16-
<th style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold;">Col. 3</th>
14+
<th style = "font-weight: bold; max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">Col. 1</th>
15+
<th style = "font-weight: bold; max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">Col. 2</th>
16+
<th style = "font-weight: bold; max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">Col. 3</th>
1717
</tr>
1818
</thead>
1919
<tbody>
2020
<tr class = "dataRow">
21-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(1, 1)</td>
22-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(1, 2)</td>
23-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(1, 3)</td>
21+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(1, 1)</td>
22+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(1, 2)</td>
23+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(1, 3)</td>
2424
</tr>
2525
<tr class = "dataRow">
26-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(2, 1)</td>
27-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(2, 2)</td>
28-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(2, 3)</td>
26+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(2, 1)</td>
27+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(2, 2)</td>
28+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(2, 3)</td>
2929
</tr>
3030
<tr class = "dataRow">
31-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(3, 1)</td>
32-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(3, 2)</td>
33-
<td style = "text-align: right; max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(3, 3)</td>
31+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(3, 1)</td>
32+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(3, 2)</td>
33+
<td style = "max-width: 30px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap;">(3, 3)</td>
3434
</tr>
3535
</tbody>
3636
</table>

test/backends/html/cropping.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
@testset "Bottom Cropping" begin
1111
expected = """
1212
<div>
13-
<div style = "font-style: italic; float: right;">
13+
<div style = "float: right; font-style: italic;">
1414
<span>97 columns and 98 rows omitted</span>
1515
</div>
1616
<div style = "clear: both;"></div>
1717
</div>
1818
<table>
1919
<thead>
2020
<tr class = "columnLabelRow">
21-
<th style = "text-align: right; font-weight: bold;">Col. 1</th>
22-
<th style = "text-align: right; font-weight: bold;">Col. 2</th>
23-
<th style = "text-align: right; font-weight: bold;">Col. 3</th>
21+
<th style = "font-weight: bold; text-align: right;">Col. 1</th>
22+
<th style = "font-weight: bold; text-align: right;">Col. 2</th>
23+
<th style = "font-weight: bold; text-align: right;">Col. 3</th>
2424
<td>&ctdot;</td>
2525
</tr>
2626
</thead>
@@ -61,17 +61,17 @@
6161
@testset "Middle Cropping" begin
6262
expected = """
6363
<div>
64-
<div style = "font-style: italic; float: right;">
64+
<div style = "float: right; font-style: italic;">
6565
<span>97 columns and 98 rows omitted</span>
6666
</div>
6767
<div style = "clear: both;"></div>
6868
</div>
6969
<table>
7070
<thead>
7171
<tr class = "columnLabelRow">
72-
<th style = "text-align: right; font-weight: bold;">Col. 1</th>
73-
<th style = "text-align: right; font-weight: bold;">Col. 2</th>
74-
<th style = "text-align: right; font-weight: bold;">Col. 3</th>
72+
<th style = "font-weight: bold; text-align: right;">Col. 1</th>
73+
<th style = "font-weight: bold; text-align: right;">Col. 2</th>
74+
<th style = "font-weight: bold; text-align: right;">Col. 3</th>
7575
<td>&ctdot;</td>
7676
</tr>
7777
</thead>
@@ -115,9 +115,9 @@
115115
<table>
116116
<thead>
117117
<tr class = "columnLabelRow">
118-
<th style = "text-align: right; font-weight: bold;">Col. 1</th>
119-
<th style = "text-align: right; font-weight: bold;">Col. 2</th>
120-
<th style = "text-align: right; font-weight: bold;">Col. 3</th>
118+
<th style = "font-weight: bold; text-align: right;">Col. 1</th>
119+
<th style = "font-weight: bold; text-align: right;">Col. 2</th>
120+
<th style = "font-weight: bold; text-align: right;">Col. 3</th>
121121
<td>&ctdot;</td>
122122
</tr>
123123
</thead>

test/backends/html/decorations.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<table>
1313
<thead>
1414
<tr class = "columnLabelRow">
15-
<th style = "text-align: right; color: yellow;">Col. 1</th>
16-
<th style = "text-align: right; color: yellow;">Col. 2</th>
17-
<th style = "text-align: right; color: yellow;">Col. 3</th>
15+
<th style = "color: yellow; text-align: right;">Col. 1</th>
16+
<th style = "color: yellow; text-align: right;">Col. 2</th>
17+
<th style = "color: yellow; text-align: right;">Col. 3</th>
1818
</tr>
1919
</thead>
2020
<tbody>
@@ -51,9 +51,9 @@
5151
<table>
5252
<thead>
5353
<tr class = "columnLabelRow">
54-
<th style = "text-align: right; color: yellow;">Col. 1</th>
55-
<th style = "text-align: right; color: blue;">Col. 2</th>
56-
<th style = "text-align: right; color: red;">Col. 3</th>
54+
<th style = "color: yellow; text-align: right;">Col. 1</th>
55+
<th style = "color: blue; text-align: right;">Col. 2</th>
56+
<th style = "color: red; text-align: right;">Col. 3</th>
5757
</tr>
5858
</thead>
5959
<tbody>

test/backends/html/default.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
<table>
1616
<thead>
1717
<tr class = "columnLabelRow">
18-
<th style = "text-align: right; font-weight: bold;">Col. 1</th>
19-
<th style = "text-align: right; font-weight: bold;">Col. 2</th>
20-
<th style = "text-align: right; font-weight: bold;">Col. 3</th>
21-
<th style = "text-align: right; font-weight: bold;">Col. 4</th>
22-
<th style = "text-align: right; font-weight: bold;">Col. 5</th>
23-
<th style = "text-align: right; font-weight: bold;">Col. 6</th>
18+
<th style = "font-weight: bold; text-align: right;">Col. 1</th>
19+
<th style = "font-weight: bold; text-align: right;">Col. 2</th>
20+
<th style = "font-weight: bold; text-align: right;">Col. 3</th>
21+
<th style = "font-weight: bold; text-align: right;">Col. 4</th>
22+
<th style = "font-weight: bold; text-align: right;">Col. 5</th>
23+
<th style = "font-weight: bold; text-align: right;">Col. 6</th>
2424
</tr>
2525
</thead>
2626
<tbody>

test/backends/html/divs.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<table class = "myClass">
1313
<thead>
1414
<tr class = "columnLabelRow">
15-
<th style = "text-align: right; font-weight: bold;">Col. 1</th>
16-
<th style = "text-align: right; font-weight: bold;">Col. 2</th>
15+
<th style = "font-weight: bold; text-align: right;">Col. 1</th>
16+
<th style = "font-weight: bold; text-align: right;">Col. 2</th>
1717
</tr>
1818
</thead>
1919
<tbody>
@@ -47,8 +47,8 @@
4747
<table class = "myClass">
4848
<thead>
4949
<tr class = "columnLabelRow">
50-
<th style = "text-align: right; font-weight: bold;">Col. 1</th>
51-
<th style = "text-align: right; font-weight: bold;">Col. 2</th>
50+
<th style = "font-weight: bold; text-align: right;">Col. 1</th>
51+
<th style = "font-weight: bold; text-align: right;">Col. 2</th>
5252
</tr>
5353
</thead>
5454
<tbody>
@@ -77,7 +77,7 @@
7777
<div style = "float: left;">
7878
<span>Top Left</span>
7979
</div>
80-
<div style = "font-style: italic; float: right;">
80+
<div style = "float: right; font-style: italic;">
8181
<span>Top Right</span>
8282
</div>
8383
<div style = "clear: both;"></div>
@@ -86,8 +86,8 @@
8686
<table class = "myClass">
8787
<thead>
8888
<tr class = "columnLabelRow">
89-
<th style = "text-align: right; font-weight: bold;">Col. 1</th>
90-
<th style = "text-align: right; font-weight: bold;">Col. 2</th>
89+
<th style = "font-weight: bold; text-align: right;">Col. 1</th>
90+
<th style = "font-weight: bold; text-align: right;">Col. 2</th>
9191
</tr>
9292
</thead>
9393
<tbody>

0 commit comments

Comments
 (0)