mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update browser demo to fix all errors when shift-clicking the "Fix" link.
This commit is contained in:
parent
ed325ebb56
commit
77217ce33e
1 changed files with 6 additions and 4 deletions
|
|
@ -14,6 +14,7 @@
|
||||||
var markdownit = window.markdownit({ "html": true });
|
var markdownit = window.markdownit({ "html": true });
|
||||||
var newLineRe = /\r\n|\r|\n/;
|
var newLineRe = /\r\n|\r|\n/;
|
||||||
var hashPrefix = "%m";
|
var hashPrefix = "%m";
|
||||||
|
var allLintErrors = [];
|
||||||
|
|
||||||
// Do-nothing function
|
// Do-nothing function
|
||||||
function noop() {}
|
function noop() {}
|
||||||
|
|
@ -54,8 +55,8 @@
|
||||||
"handleRuleFailures": true,
|
"handleRuleFailures": true,
|
||||||
"resultVersion": 3
|
"resultVersion": 3
|
||||||
};
|
};
|
||||||
var results = window.markdownlint.sync(options);
|
allLintErrors = window.markdownlint.sync(options).content;
|
||||||
violations.innerHTML = results.content.map(function mapResult(result) {
|
violations.innerHTML = allLintErrors.map(function mapResult(result) {
|
||||||
var ruleName = result.ruleNames.slice(0, 2).join(" / ");
|
var ruleName = result.ruleNames.slice(0, 2).join(" / ");
|
||||||
return "<em><a href='#line' target='" + result.lineNumber + "'>" +
|
return "<em><a href='#line' target='" + result.lineNumber + "'>" +
|
||||||
result.lineNumber + "</a></em> - <a href='" + result.ruleInformation +
|
result.lineNumber + "</a></em> - <a href='" + result.ruleInformation +
|
||||||
|
|
@ -123,8 +124,9 @@
|
||||||
function onViolationClick(e) {
|
function onViolationClick(e) {
|
||||||
switch (e.target.hash) {
|
switch (e.target.hash) {
|
||||||
case "#fix":
|
case "#fix":
|
||||||
var error = JSON.parse(decodeURIComponent(e.target.target));
|
var errors = e.shiftKey ?
|
||||||
var errors = [ error ];
|
allLintErrors :
|
||||||
|
[ JSON.parse(decodeURIComponent(e.target.target)) ];
|
||||||
var fixed =
|
var fixed =
|
||||||
window.markdownlintRuleHelpers.applyFixes(markdown.value, errors);
|
window.markdownlintRuleHelpers.applyFixes(markdown.value, errors);
|
||||||
markdown.value = fixed;
|
markdown.value = fixed;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue