Render element attributes in the order they were defined
`attributes` uses a LinkedHashMap, so the ordering is stable with the
input
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7a6fe79..d4ace80 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
## 2.0.3
+* Render element attributes in the order they were defined.
+ Aligns more closely with the strict spec definition.
* Added 68 new GitHub emojis.
## 2.0.2
diff --git a/lib/src/html_renderer.dart b/lib/src/html_renderer.dart
index 95e0cda..d77c6f2 100644
--- a/lib/src/html_renderer.dart
+++ b/lib/src/html_renderer.dart
@@ -66,12 +66,8 @@
buffer.write('<${element.tag}');
- // Sort the keys so that we generate stable output.
- var attributeNames = element.attributes.keys.toList();
- attributeNames.sort((a, b) => a.compareTo(b));
-
- for (var name in attributeNames) {
- buffer.write(' $name="${element.attributes[name]}"');
+ for (var entry in element.attributes.entries) {
+ buffer.write(' ${entry.key}="${entry.value}"');
}
// attach header anchor ids generated from text
diff --git a/test/original/inline_images.unit b/test/original/inline_images.unit
index 9ce0674..5e38830 100644
--- a/test/original/inline_images.unit
+++ b/test/original/inline_images.unit
@@ -2,19 +2,19 @@
![](http://foo.com/foo.png)
<<<
-<p><img alt="" src="http://foo.com/foo.png" /></p>
+<p><img src="http://foo.com/foo.png" alt="" /></p>
>>> alternate text
![alternate text](http://foo.com/foo.png)
<<<
-<p><img alt="alternate text" src="http://foo.com/foo.png" /></p>
+<p><img src="http://foo.com/foo.png" alt="alternate text" /></p>
>>> title
![](http://foo.com/foo.png "optional title")
<<<
-<p><img alt="" src="http://foo.com/foo.png" title="optional title" /></p>
+<p><img src="http://foo.com/foo.png" alt="" title="optional title" /></p>
>>> invalid alt text
![`alt`](http://foo.com/foo.png)
<<<
-<p><img alt="alt" src="http://foo.com/foo.png" /></p>
+<p><img src="http://foo.com/foo.png" alt="alt" /></p>
diff --git a/test/original/inline_links.unit b/test/original/inline_links.unit
index 74afe5a..4bfd85a 100644
--- a/test/original/inline_links.unit
+++ b/test/original/inline_links.unit
@@ -17,17 +17,17 @@
links [![](/are.png)](http://foo.com) awesome
<<<
-<p>links <a href="http://foo.com"><img alt="" src="/are.png" /></a> awesome</p>
+<p>links <a href="http://foo.com"><img src="/are.png" alt="" /></a> awesome</p>
>>> image with alt inside link
links [![my alt](/are.png)](http://foo.com) awesome
<<<
-<p>links <a href="http://foo.com"><img alt="my alt" src="/are.png" /></a> awesome</p>
+<p>links <a href="http://foo.com"><img src="/are.png" alt="my alt" /></a> awesome</p>
>>> image with title inside link
links [![](/are.png "my title")](http://foo.com) awesome
<<<
-<p>links <a href="http://foo.com"><img alt="" src="/are.png" title="my title" /></a> awesome</p>
+<p>links <a href="http://foo.com"><img src="/are.png" alt="" title="my title" /></a> awesome</p>
>>> no URL
links [are]() awesome
diff --git a/test/original/reference_images.unit b/test/original/reference_images.unit
index 2444a11..b098d24 100644
--- a/test/original/reference_images.unit
+++ b/test/original/reference_images.unit
@@ -4,31 +4,31 @@
[foo]: http://foo.com/foo.png
<<<
-<p><img alt="" src="http://foo.com/foo.png" /></p>
+<p><img src="http://foo.com/foo.png" alt="" /></p>
>>> alternate text
![alternate text][foo]
[foo]: http://foo.com/foo.png
<<<
-<p><img alt="alternate text" src="http://foo.com/foo.png" /></p>
+<p><img src="http://foo.com/foo.png" alt="alternate text" /></p>
>>> title
![][foo]
[foo]: http://foo.com/foo.png "optional title"
<<<
-<p><img alt="" src="http://foo.com/foo.png" title="optional title" /></p>
+<p><img src="http://foo.com/foo.png" alt="" title="optional title" /></p>
>>> invalid alt text
![`alt`][foo]
[foo]: http://foo.com/foo.png "optional title"
<<<
-<p><img alt="alt" src="http://foo.com/foo.png" title="optional title" /></p>
+<p><img src="http://foo.com/foo.png" alt="alt" title="optional title" /></p>
>>> shortcut reference image
![foo]
[foo]: http://foo.com/foo.png
<<<
-<p><img alt="foo" src="http://foo.com/foo.png" /></p>
+<p><img src="http://foo.com/foo.png" alt="foo" /></p>
diff --git a/test/original/reference_links.unit b/test/original/reference_links.unit
index 6b22081..6c217a5 100644
--- a/test/original/reference_links.unit
+++ b/test/original/reference_links.unit
@@ -88,4 +88,4 @@
[coverage_page]:https://coveralls.io/github/yeradis/stay_points.dart?branch=master
[coverage_status]: https://coveralls.io/repos/github/yeradis/stay_points.dart/badge.svg?branch=master
<<<
-<p><a href="https://coveralls.io/github/yeradis/stay_points.dart?branch=master"><img alt="Coverage Status" src="https://coveralls.io/repos/github/yeradis/stay_points.dart/badge.svg?branch=master" /></a></p>
\ No newline at end of file
+<p><a href="https://coveralls.io/github/yeradis/stay_points.dart?branch=master"><img src="https://coveralls.io/repos/github/yeradis/stay_points.dart/badge.svg?branch=master" alt="Coverage Status" /></a></p>
\ No newline at end of file
diff --git a/tool/common_mark_stats.json b/tool/common_mark_stats.json
index 505167a..5949d7b 100644
--- a/tool/common_mark_stats.json
+++ b/tool/common_mark_stats.json
@@ -341,26 +341,26 @@
"158": "loose"
},
"Images": {
- "543": "loose",
+ "543": "strict",
"544": "loose",
"545": "fail",
- "546": "loose",
+ "546": "strict",
"547": "loose",
"548": "loose",
- "549": "loose",
- "550": "loose",
- "551": "loose",
- "552": "loose",
- "553": "loose",
- "554": "loose",
- "555": "loose",
- "556": "loose",
- "557": "loose",
+ "549": "strict",
+ "550": "strict",
+ "551": "strict",
+ "552": "strict",
+ "553": "strict",
+ "554": "strict",
+ "555": "strict",
+ "556": "strict",
+ "557": "strict",
"558": "loose",
- "559": "loose",
- "560": "loose",
+ "559": "strict",
+ "560": "strict",
"561": "loose",
- "562": "loose",
+ "562": "strict",
"563": "strict",
"564": "strict"
},
@@ -436,10 +436,10 @@
"485": "strict",
"486": "strict",
"487": "strict",
- "488": "loose",
+ "488": "strict",
"489": "strict",
"490": "strict",
- "491": "loose",
+ "491": "strict",
"492": "fail",
"493": "strict",
"494": "strict",
@@ -450,7 +450,7 @@
"499": "strict",
"500": "strict",
"501": "strict",
- "502": "loose",
+ "502": "strict",
"503": "strict",
"504": "strict",
"505": "fail",
diff --git a/tool/gfm_stats.json b/tool/gfm_stats.json
index 7151ef7..aae6a73 100644
--- a/tool/gfm_stats.json
+++ b/tool/gfm_stats.json
@@ -362,26 +362,26 @@
"158": "loose"
},
"Images": {
- "563": "loose",
+ "563": "strict",
"564": "loose",
"565": "fail",
- "566": "loose",
+ "566": "strict",
"567": "loose",
"568": "loose",
- "569": "loose",
- "570": "loose",
- "571": "loose",
- "572": "loose",
- "573": "loose",
- "574": "loose",
- "575": "loose",
- "576": "loose",
- "577": "loose",
+ "569": "strict",
+ "570": "strict",
+ "571": "strict",
+ "572": "strict",
+ "573": "strict",
+ "574": "strict",
+ "575": "strict",
+ "576": "strict",
+ "577": "strict",
"578": "loose",
- "579": "loose",
- "580": "loose",
+ "579": "strict",
+ "580": "strict",
"581": "loose",
- "582": "loose",
+ "582": "strict",
"583": "strict",
"584": "strict"
},
@@ -458,10 +458,10 @@
"505": "strict",
"506": "strict",
"507": "strict",
- "508": "loose",
+ "508": "strict",
"509": "strict",
"510": "strict",
- "511": "loose",
+ "511": "strict",
"512": "fail",
"513": "strict",
"514": "strict",
@@ -472,7 +472,7 @@
"519": "strict",
"520": "strict",
"521": "strict",
- "522": "loose",
+ "522": "strict",
"523": "strict",
"524": "strict",
"525": "fail",