-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cc31bb3
Showing
5 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
npm-debug.log | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
linter-markdownlint | ||
========================= | ||
|
||
This linter plugin for [Linter](https://github.com/AtomLinter/Linter) provides an interface to [markdownlint](https://github.com/mivok/markdownlint). It will be used with files that have the “Markdown” syntax. | ||
|
||
## Installation | ||
Linter package must be installed in order to use this plugin. If Linter is not installed, please follow the instructions [here](https://github.com/AtomLinter/Linter). | ||
|
||
### mdl installation | ||
Before using this plugin, you must ensure that `mdl` is installed on your system. To install `mdl`, do the following: | ||
|
||
1. Install [ruby](https://www.ruby-lang.org/). | ||
|
||
2. Install [markdownlint](https://github.com/mivok/markdownlint) by typing the following in a terminal: | ||
``` | ||
gem install mdl | ||
``` | ||
|
||
Now you can proceed to install the linter-markdownlint plugin. | ||
|
||
### Plugin installation | ||
``` | ||
$ apm install linter-markdownlint | ||
``` | ||
|
||
## Settings | ||
You can configure linter-markdownlint by editing ~/.atom/config.cson (choose Open Your Config in Atom menu): | ||
|
||
``` | ||
'linter-markdownlint': | ||
'executableDir': null # markdownlint directory path. | ||
'binaryName': mdl # mdl binary name. | ||
``` | ||
Run `which mdl` to find the path, | ||
if you using rbenv run `rbenv which mdl` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{BufferedProcess, CompositeDisposable} = require 'atom' | ||
|
||
class Parser | ||
@match: (line) -> | ||
if m = /(.+):([0-9]+): +(MD[0-9]{3}) +(.+)/.exec line | ||
type: 'Error' | ||
message: "#{m[3]}: #{m[4]}" | ||
lineStart: m[2] | ||
lineEnd: m[2] | ||
charStart: 1 | ||
charEnd: 1 | ||
@parse: (data) => | ||
errors = (@match(line) for line in data) | ||
errors = (error for error in errors when error?) | ||
if errors.length == 0 | ||
passed: true | ||
else | ||
passed: false | ||
errors: errors | ||
|
||
class Command | ||
@setExecutablePath: (path) => | ||
@executablePath = path | ||
|
||
@getExecutablePath: => | ||
@executablePath || 'mdl' | ||
|
||
module.exports = | ||
config: | ||
executablePath: | ||
type: 'string' | ||
default: 'mdl' | ||
description: 'Path to mdl executable' | ||
activate: -> | ||
@subscriptions = new CompositeDisposable | ||
@subscriptions.add atom.config.observe 'linter-example.executablePath', | ||
(executablePath) -> | ||
Command.setExecutablePath(executablePath) | ||
deactivate: -> | ||
@subscriptions.dispose() | ||
provideLinter: -> | ||
provider = | ||
grammarScopes: ['source.gfm', 'source.pfm'] | ||
scope: 'file' | ||
lintOnFly: false | ||
lint: (TextEditor) => | ||
return new Promise (resolve, reject) => | ||
filePath = TextEditor.getPath() | ||
lines = [] | ||
console.log Command.getExecutablePath() | ||
process = new BufferedProcess | ||
command: Command.getExecutablePath() | ||
args: [filePath] | ||
stdout: (data) -> | ||
lines.push(line) for line in data.split('\n') | ||
exit: (code) -> | ||
return resolve [] if code is 0 | ||
info = Parser.parse lines | ||
return resolve [] unless info? | ||
return resolve [] if info.passed | ||
resolve info.errors.map (error) -> | ||
type: error.type, | ||
text: error.message, | ||
filePath: error.file or filePath, | ||
range: [ | ||
# Atom expects ranges to be 0-based | ||
[error.lineStart - 1, error.charStart - 1], | ||
[error.lineEnd - 1, error.charEnd] | ||
] | ||
|
||
process.onWillThrowError ({error,handle}) -> | ||
atom.notifications.addError "Failed to run #{@executablePath}", | ||
detail: "#{error.message}" | ||
dismissable: true | ||
handle() | ||
resolve [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "linter-markdownlint", | ||
"activationCommands": {}, | ||
"main": "./lib/init", | ||
"version": "1.0.0", | ||
"description": "Lint Markdown with mdl", | ||
"keywords": ["linter", "mdl", "markdown", "markdownlint"], | ||
"activationCommands": {}, | ||
"repository": "https://github.com/lloeki/linter-markdownlint", | ||
"license": "MIT", | ||
"engines": { | ||
"atom": ">=1.0.0 <2.0.0" | ||
}, | ||
"dependencies": {}, | ||
"providedServices": { | ||
"linter": { | ||
"versions": { | ||
"1.0.0": "provideLinter" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# foo | ||
|
||
## bar | ||
lorem ipsum | ||
|
||
# baz | ||
|
||
foo | ||
--- | ||
|
||
1. foo | ||
2. bar | ||
baz |