Find and fix a gnarly oversight with using the wrong 'Element' class Thanks, strong-mode
diff --git a/pkgs/markdown/tool/common_mark_stats.dart b/pkgs/markdown/tool/common_mark_stats.dart index 6d50731..19be5f0 100644 --- a/pkgs/markdown/tool/common_mark_stats.dart +++ b/pkgs/markdown/tool/common_mark_stats.dart
@@ -7,8 +7,9 @@ import 'package:args/args.dart' show ArgParser; import 'package:collection/collection.dart'; +import 'package:html/dom.dart' as dom; import 'package:html/parser.dart' show parseFragment; -import 'package:markdown/markdown.dart'; +import 'package:markdown/markdown.dart' show markdownToHtml; import 'package:path/path.dart' as p; const _commonMarkTests = 'common_mark_tests.json'; @@ -125,7 +126,8 @@ } /// Compare two DOM trees for equality. -bool compareHtml(List<Element> expectedElements, List<Element> actualElements) { +bool compareHtml( + List<dom.Element> expectedElements, List<dom.Element> actualElements) { if (expectedElements.length != actualElements.length) { return false; } @@ -138,34 +140,32 @@ return false; } - if (expected is Element) { - if (expected.localName != actual.localName) { + if (expected.localName != actual.localName) { + return false; + } + + if (expected.attributes.length != actual.attributes.length) { + return false; + } + + var expectedAttrKeys = expected.attributes.keys.toList(); + expectedAttrKeys.sort(); + + var actualAttrKeys = actual.attributes.keys.toList(); + actualAttrKeys.sort(); + + for (var attrNum = 0; attrNum < actualAttrKeys.length; attrNum++) { + var expectedAttrKey = expectedAttrKeys[attrNum]; + var actualAttrKey = actualAttrKeys[attrNum]; + + if (expectedAttrKey != actualAttrKey) { return false; } - if (expected.attributes.length != actual.attributes.length) { + if (expected.attributes[expectedAttrKey] != + actual.attributes[actualAttrKey]) { return false; } - - var expectedAttrKeys = expected.attributes.keys.toList(); - expectedAttrKeys.sort(); - - var actualAttrKeys = actual.attributes.keys.toList(); - actualAttrKeys.sort(); - - for (var attrNum = 0; attrNum < actualAttrKeys.length; attrNum++) { - var expectedAttrKey = expectedAttrKeys[attrNum]; - var actualAttrKey = actualAttrKeys[attrNum]; - - if (expectedAttrKey != actualAttrKey) { - return false; - } - - if (expected.attributes[expectedAttrKey] != - actual.attributes.keys[actualAttrKey]) { - return false; - } - } } var childrenEqual = compareHtml(expected.children, actual.children);
diff --git a/pkgs/markdown/tool/common_mark_stats.json b/pkgs/markdown/tool/common_mark_stats.json index b5cfaaf..7f783f3 100644 --- a/pkgs/markdown/tool/common_mark_stats.json +++ b/pkgs/markdown/tool/common_mark_stats.json
@@ -3,14 +3,14 @@ "30": true, "31": true, "32": true, - "33": true, + "33": false, "34": true, "35": true, "36": true, "37": false, "38": true, "39": true, - "40": true, + "40": false, "41": true, "42": true, "43": true, @@ -18,7 +18,7 @@ "45": true, "46": true, "47": true, - "48": true + "48": false }, "Autolinks": { "557": true, @@ -30,7 +30,7 @@ "563": true, "564": false, "565": false, - "566": true, + "566": false, "567": false, "568": false, "569": true, @@ -50,11 +50,11 @@ "290": true, "291": true, "292": true, - "293": true, + "293": false, "294": true, - "295": true, - "296": true, - "297": true + "295": false, + "296": false, + "297": false }, "Blank lines": { "187": true @@ -99,7 +99,7 @@ "319": true, "320": true, "321": true, - "322": true, + "322": false, "323": false, "324": true }, @@ -179,7 +179,7 @@ "397": false, "398": false, "399": true, - "400": true, + "400": false, "401": true, "402": true, "403": false, @@ -194,8 +194,8 @@ "412": true, "413": false, "414": true, - "415": true, - "416": true, + "415": false, + "416": false, "417": true, "418": true, "419": true, @@ -224,8 +224,8 @@ "442": false, "443": true, "444": true, - "445": true, - "446": true, + "445": false, + "446": false, "447": true, "448": true, "449": true, @@ -242,8 +242,8 @@ "302": true, "303": true, "304": true, - "305": true, - "306": true, + "305": false, + "306": false, "307": true, "308": true, "309": true @@ -267,14 +267,14 @@ "102": true, "103": true, "104": true, - "105": true, + "105": false, "106": true, "107": true, "108": true, "109": true, "110": true, "111": true, - "112": true, + "112": false, "113": false }, "Hard line breaks": { @@ -340,23 +340,23 @@ }, "Images": { "535": true, - "536": true, - "537": true, - "538": true, - "539": true, - "540": true, + "536": false, + "537": false, + "538": false, + "539": false, + "540": false, "541": true, "542": false, "543": true, - "544": true, + "544": false, "545": true, "546": true, "547": true, - "548": true, + "548": false, "549": true, "550": true, "551": true, - "552": true, + "552": false, "553": true, "554": true, "555": true, @@ -390,9 +390,9 @@ "163": true, "164": false, "165": true, - "166": true, + "166": false, "167": true, - "168": true, + "168": false, "169": true, "170": true, "171": true, @@ -413,16 +413,16 @@ "459": true, "460": true, "461": false, - "462": true, - "463": true, + "462": false, + "463": false, "464": false, - "465": true, - "466": true, - "467": true, + "465": false, + "466": false, + "467": false, "468": true, - "469": true, - "470": true, - "471": true, + "469": false, + "470": false, + "471": false, "472": false, "473": false, "474": true, @@ -437,13 +437,13 @@ "483": true, "484": false, "485": false, - "486": true, - "487": true, + "486": false, + "487": false, "488": true, "489": true, "490": true, "491": true, - "492": true, + "492": false, "493": true, "494": true, "495": true, @@ -455,13 +455,13 @@ "501": true, "502": true, "503": true, - "504": true, + "504": false, "505": true, "506": true, "507": false, "508": true, "509": true, - "510": true, + "510": false, "511": true, "512": false, "513": true, @@ -481,7 +481,7 @@ "527": true, "528": true, "529": true, - "530": true, + "530": false, "531": true, "532": true, "533": true, @@ -501,13 +501,13 @@ "223": true, "224": false, "225": false, - "226": true, + "226": false, "227": false, - "228": true, - "229": true, + "228": false, + "229": false, "230": true, "231": false, - "232": true, + "232": false, "233": true, "234": false, "235": false, @@ -533,14 +533,14 @@ "255": false, "256": false, "257": true, - "258": true, + "258": false, "259": false }, "Lists": { "260": false, "261": false, "262": true, - "263": true, + "263": false, "264": false, "265": true, "266": false, @@ -582,10 +582,10 @@ "579": true, "580": true, "581": true, - "582": true, + "582": false, "583": true, "584": true, - "585": true, + "585": false, "586": true, "587": false, "588": true, @@ -596,13 +596,13 @@ "593": true, "594": true, "595": true, - "596": true + "596": false }, "Setext headings": { "49": true, "50": false, "51": true, - "52": true, + "52": false, "53": true, "54": false, "55": true,
diff --git a/pkgs/markdown/tool/common_mark_stats.txt b/pkgs/markdown/tool/common_mark_stats.txt index 48523fc..7082c31 100644 --- a/pkgs/markdown/tool/common_mark_stats.txt +++ b/pkgs/markdown/tool/common_mark_stats.txt
@@ -1,27 +1,27 @@ - 18 of 19 – 94.7% ATX headings - 11 of 19 – 57.9% Autolinks - 12 of 13 – 92.3% Backslash escapes + 15 of 19 – 78.9% ATX headings + 10 of 19 – 52.6% Autolinks + 8 of 13 – 61.5% Backslash escapes 1 of 1 – 100.0% Blank lines 18 of 25 – 72.0% Block quotes - 14 of 15 – 93.3% Code spans - 86 of 129 – 66.7% Emphasis and strong emphasis - 12 of 12 – 100.0% Entity and numeric character references - 26 of 27 – 96.3% Fenced code blocks + 13 of 15 – 86.7% Code spans + 81 of 129 – 62.8% Emphasis and strong emphasis + 10 of 12 – 83.3% Entity and numeric character references + 24 of 27 – 88.9% Fenced code blocks 15 of 15 – 100.0% Hard line breaks 42 of 42 – 100.0% HTML blocks - 21 of 22 – 95.5% Images + 13 of 22 – 59.1% Images 10 of 12 – 83.3% Indented code blocks 1 of 1 – 100.0% Inlines - 13 of 23 – 56.5% Link reference definitions - 66 of 81 – 81.5% Links - 25 of 47 – 53.2% List items - 4 of 24 – 16.7% Lists + 11 of 23 – 47.8% Link reference definitions + 52 of 81 – 64.2% Links + 20 of 47 – 42.6% List items + 3 of 24 – 12.5% Lists 8 of 8 – 100.0% Paragraphs 1 of 1 – 100.0% Precedence - 18 of 21 – 85.7% Raw HTML - 16 of 26 – 61.5% Setext headings + 15 of 21 – 71.4% Raw HTML + 15 of 26 – 57.7% Setext headings 2 of 2 – 100.0% Soft line breaks 6 of 9 – 66.7% Tabs 3 of 3 – 100.0% Textual content 16 of 19 – 84.2% Thematic breaks - 465 of 616 – 75.5% TOTAL + 413 of 616 – 67.0% TOTAL
diff --git a/pkgs/markdown/tool/dartdoc-compare.dart b/pkgs/markdown/tool/dartdoc-compare.dart index 24c23ae..5b9cff7 100644 --- a/pkgs/markdown/tool/dartdoc-compare.dart +++ b/pkgs/markdown/tool/dartdoc-compare.dart
@@ -68,7 +68,7 @@ return result == 0; } - run_dartdoc(markdown_ref, package) { + String run_dartdoc(markdown_ref, package) { print("=========================================================="); print("Running dartdoc for ${markdown_ref}..."); print("=========================================================="); @@ -77,7 +77,8 @@ if (!sdk) system('pub', ['get']); var out = Directory.systemTemp .createTempSync("dartdoc-compare-${markdown_ref}__"); - var sdk_options = sdk ? ["--sdk-docs", "--dart-sdk=$package"] : []; + var sdk_options = + sdk ? ["--sdk-docs", "--dart-sdk=$package"] : <String>[]; var cmd = "dart"; var args = ["${dartdoc_bin}", "--output=${out.path}"] ..addAll(sdk_options); @@ -107,7 +108,7 @@ return system('pub', ['get']); } - static system(cmd, args) { + static system(String cmd, List<String> args) { var result = Process.runSync(cmd, args); print(result.stdout); print(result.stderr);