diff --git a/test/detailed-results-MD001-MD010.md.fixed b/test/detailed-results-MD001-MD010.md.fixed
new file mode 100644
index 00000000..428b8d44
--- /dev/null
+++ b/test/detailed-results-MD001-MD010.md.fixed
@@ -0,0 +1,30 @@
+## One
+
+#### Two
+
+### Three ###
+
+* Alpha
+ * Bravo
+
+- Charlie
+
+* Delta
+ * Echo
+
+Text
+
+Text text
+
+ 1. One
+ 2. Two
+ 3. Three
+ 4. Four
+5. Five
+ 6. Six
+ 7. Seven
+ 8. Eight
+ 9. Nine
+10. Ten
+ 11. Eleven
+12. Twelve
diff --git a/test/detailed-results-MD011-MD021.md.fixed b/test/detailed-results-MD011-MD021.md.fixed
new file mode 100644
index 00000000..04a11e86
--- /dev/null
+++ b/test/detailed-results-MD011-MD021.md.fixed
@@ -0,0 +1,23 @@
+# Top level heading
+
+
+
+A [reversed](link) example.
+
+123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
+
+## 123456789 123456789 123456789 123456789 123456789 123456789
+
+ $ command with no output
+
+## No space A
+
+## Multiple spaces B
+
+## No space C ####No space C ##
+
+## No space D #### No space D##
+
+## Multiple spaces E #### Multiple spaces E ##
+
+## Multiple spaces F #### Multiple spaces F ##
diff --git a/test/detailed-results-MD022-MD030.md.fixed b/test/detailed-results-MD022-MD030.md.fixed
new file mode 100644
index 00000000..ec0b4b97
--- /dev/null
+++ b/test/detailed-results-MD022-MD030.md.fixed
@@ -0,0 +1,19 @@
+# Heading
+
+Text
+
+# Heading
+
+## Another heading
+
+> Multiple spaces
+> Blank line above
+
+1. Alpha
+3. Beta
+
+> > Multiple spaces, multiple blockquotes
+> >
+> > > Multiple spaces, multiple blockquotes
+> > >
+> > > Multiple spaces, multiple blockquotes
diff --git a/test/detailed-results-MD030-warning-message.md.fixed b/test/detailed-results-MD030-warning-message.md.fixed
new file mode 100644
index 00000000..b7b7834b
--- /dev/null
+++ b/test/detailed-results-MD030-warning-message.md.fixed
@@ -0,0 +1,13 @@
+#
+
+-
+
+1.
+
+- a
+
+1. a
+
+- a
+
+1. a
diff --git a/test/detailed-results-MD031-MD040.md.fixed b/test/detailed-results-MD031-MD040.md.fixed
new file mode 100644
index 00000000..5effe1cf
--- /dev/null
+++ b/test/detailed-results-MD031-MD040.md.fixed
@@ -0,0 +1,66 @@
+```js
+debugger;
+```
+
+* List
+
+Inline
HTML
+
+Bare link
+
+---
+***
+
+*Emphasis*
+
+Space *inside* emphasis
+
+Space `insidecode span
+
+Space [inside](link) text
+
+```
+```
+
+space ``insideode
+space `inside` of `codeelements
+`space` inside `of` code `elements
+space ``inside`` of ``codelements
+``` embedded backtick
+embedded backtick```
+
+some *space* in *some* emphasis
+some *space* in *some* emphasis
+some *space* in **some** emphasis
+some _space_ in _some_ emphasis
+some __space__ in __some__ emphasis
+
+Text
+text `code
+span
+span` text
+text.
+
+Text
+text `code
+code
+span` text
+text.
+
+* List
+
+---
+
+Text
+text ```code
+span code
+code
+span code
+span code``` text
+text
+text text ````code
+span code
+span
+span code
+span```` text
+text.
diff --git a/test/detailed-results-MD041-MD050.md.fixed b/test/detailed-results-MD041-MD050.md.fixed
new file mode 100644
index 00000000..adc358df
--- /dev/null
+++ b/test/detailed-results-MD041-MD050.md.fixed
@@ -0,0 +1,27 @@
+Not a heading
+
+An [empty]() link
+
+An [empty](#) link with fragment
+
+An [empty](<>) link with angle brackets
+
+This is a test file for the markdownlint package.
+
+This is a paragraph
+about markdownlint
+that capitalizes the
+name wrong twice:
+markdownlint.
+
+A [normal](link) and an [empty one]() and a [fragment](#one).
+
+An image without alternate text 
+
+```text
+Fenced code
+```
+
+ Indented code
+
+Missing newline character
diff --git a/test/detailed-results-blanks-around-headings-0-2.md.fixed b/test/detailed-results-blanks-around-headings-0-2.md.fixed
new file mode 100644
index 00000000..2356153d
--- /dev/null
+++ b/test/detailed-results-blanks-around-headings-0-2.md.fixed
@@ -0,0 +1,26 @@
+# Blanks Around Headings
+
+
+## Apple
+
+
+Text
+## Banana
+
+
+Text
+## Cherry
+
+
+Text
+## Durian ##
+
+
+Text
+
+---
+Elderberry
+----------
+
+Text
+## Fig
diff --git a/test/detailed-results-blanks-around-headings-3-0.md.fixed b/test/detailed-results-blanks-around-headings-3-0.md.fixed
new file mode 100644
index 00000000..6b7d263a
--- /dev/null
+++ b/test/detailed-results-blanks-around-headings-3-0.md.fixed
@@ -0,0 +1,30 @@
+# Blanks Around Headings
+
+
+
+## Apple
+Text
+
+
+
+## Banana
+Text
+
+
+
+## Cherry
+Text
+
+
+
+## Durian ##
+Text
+
+
+Elderberry
+----------
+Text
+
+
+
+## Fig
diff --git a/test/detailed-results-blanks-around-headings.md.fixed b/test/detailed-results-blanks-around-headings.md.fixed
new file mode 100644
index 00000000..0271c369
--- /dev/null
+++ b/test/detailed-results-blanks-around-headings.md.fixed
@@ -0,0 +1,26 @@
+# Blanks Around Headings
+
+## Apple
+
+Text
+
+## Banana
+
+Text
+
+## Cherry
+
+Text
+
+## Durian ##
+
+Text
+
+---
+
+Elderberry
+----------
+
+Text
+
+## Fig
diff --git a/test/detailed-results-front-matter.md.fixed b/test/detailed-results-front-matter.md.fixed
new file mode 100644
index 00000000..3658daee
--- /dev/null
+++ b/test/detailed-results-front-matter.md.fixed
@@ -0,0 +1,6 @@
+---
+front: matter
+---
+Text
+
+Text
diff --git a/test/detailed-results-html-tags.md.fixed b/test/detailed-results-html-tags.md.fixed
new file mode 100644
index 00000000..0bbf4773
--- /dev/null
+++ b/test/detailed-results-html-tags.md.fixed
@@ -0,0 +1,107 @@
+# Detailed HTML Results
+
+Text
+
+Block block
+
+Text inline inline text
+
+Text
+
+Block block
+
+Text inline inline text
+
+Text
+
+
+Block
+block block block
+block
+block block block
+block
+block block block block block
+block block block block block
+
+
+Text
+
+Block block
+
+Text inline inline text
+
+Text
+
+Block block
+
+Text inline inline text
+
+Text
+
+Text inline text inline text inline text
+
+Text inline text inline text inline text
+
+Text
+
+\Block block\
+
+\\Block block\\
+
+Block block
+
+Text \inline inline\ text
+
+Text \\inline inline\\ text
+
+Text inline inline text
+
+Text
+
+> Text inline inline text
+> text inline inline text
+
+Text
+
+ Text inline inline text
+ text inline inline text
+
+Text
+
+```html
+Text inline inline text
+text inline inline text
+```
+
+Text
+
+``
+
+Text ```` text
+
+Text `` text ```` text `````` text
+
+Text `` text inline text
+
+Text ``text text`` text
+
+Text
+
+Text inline text
+text
text
+
+Text
+
+ is an email autolink.
+
+Another email autolink: .
+
+Text
+
+ is an HTML element.
+
+But is not an autolink or HTML element.
+And neither is .
+Nor <123abc>.
+
+Text
diff --git a/test/detailed-results-links.md.fixed b/test/detailed-results-links.md.fixed
new file mode 100644
index 00000000..cadb3eb7
--- /dev/null
+++ b/test/detailed-results-links.md.fixed
@@ -0,0 +1,26 @@
+# Detailed Link Results
+
+Text text
+
+Text text text
+
+Text text text
+
+Text `code https://example.com/code code` text text
+
+> Text text text
+
+Text
+text
+text
+text
+
+```text
+Code https://example.com/code?type=fence code
+```
+
+ Code https://example.com/code?type=indent code
+
+Text more text still more text done
+
+Text more \* text https://example.com/same more \[ text done
diff --git a/test/detailed-results-ordered-list-item-prefix-single.md.fixed b/test/detailed-results-ordered-list-item-prefix-single.md.fixed
new file mode 100644
index 00000000..1a6959b5
--- /dev/null
+++ b/test/detailed-results-ordered-list-item-prefix-single.md.fixed
@@ -0,0 +1,3 @@
+# Ordered list examples
+
+9. Item
diff --git a/test/detailed-results-ordered-list-item-prefix-zero.md.fixed b/test/detailed-results-ordered-list-item-prefix-zero.md.fixed
new file mode 100644
index 00000000..f8eac253
--- /dev/null
+++ b/test/detailed-results-ordered-list-item-prefix-zero.md.fixed
@@ -0,0 +1,19 @@
+# Ordered list examples
+
+text
+
+0. Item
+0. Item
+0. Item
+
+text
+
+1. Item
+1. Item
+1. Item
+
+text
+
+1. Item
+2. Item
+3. Item
diff --git a/test/markdownlint-test.js b/test/markdownlint-test.js
index 1c39d2e0..f73e8390 100644
--- a/test/markdownlint-test.js
+++ b/test/markdownlint-test.js
@@ -35,9 +35,10 @@ function promisify(func, ...args) {
function createTestForFile(file) {
return function testForFile(test) {
- test.expect(2);
const detailedResults = /[/\\]detailed-results-/.test(file);
+ test.expect(detailedResults ? 3 : 2);
const resultsFile = file.replace(/\.md$/, ".results.json");
+ const fixedFile = file.replace(/\.md$/, ".md.fixed");
const configFile = file.replace(/\.md$/, ".json");
let mergedConfig = null;
const actualPromise = promisify(fs.stat, configFile)
@@ -62,9 +63,34 @@ function createTestForFile(file) {
});
})
.then(
- function convertResultVersion2To0(resultVersion2) {
+ function diffFixedFiles(resultVersion2or3) {
+ return detailedResults ?
+ Promise.all([
+ promisify(markdownlint, {
+ "files": [ file ],
+ "config": mergedConfig,
+ "resultVersion": 3
+ }),
+ promisify(fs.readFile, file, helpers.utf8Encoding),
+ promisify(fs.readFile, fixedFile, helpers.utf8Encoding)
+ ])
+ .then(function validateApplyFixes(fulfillments) {
+ const [ resultVersion3, content, expected ] = fulfillments;
+ const errors = resultVersion3[file];
+ const actual = helpers.applyFixes(content, errors);
+ // Uncomment the following line to update *.md.fixed files
+ // fs.writeFileSync(fixedFile, actual, helpers.utf8Encoding);
+ test.equal(actual, expected,
+ "Unexpected output from applyFixes.");
+ return resultVersion2or3;
+ }) :
+ resultVersion2or3;
+ }
+ )
+ .then(
+ function convertResultVersion2To0(resultVersion2or3) {
const result0 = {};
- const result2or3 = resultVersion2[file];
+ const result2or3 = resultVersion2or3[file];
result2or3.forEach(function forResult(result) {
const ruleName = result.ruleNames[0];
const lineNumbers = result0[ruleName] || [];