mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Allow overlapping and differently-cased names for MD044/proper-names (fixes #60).
This commit is contained in:
parent
d63143b38e
commit
edd426bbaa
4 changed files with 75 additions and 3 deletions
11
lib/rules.js
11
lib/rules.js
|
|
@ -1157,9 +1157,14 @@ module.exports = [
|
||||||
.forEach(function forLine(line, index) {
|
.forEach(function forLine(line, index) {
|
||||||
var match = null;
|
var match = null;
|
||||||
while ((match = anyNameRe.exec(line)) !== null) {
|
while ((match = anyNameRe.exec(line)) !== null) {
|
||||||
if (!bareUrlRe.test(match[0])) {
|
var fullMatch = match[0];
|
||||||
var lineNumber = token.lineNumber + index + fenceOffset;
|
if (!bareUrlRe.test(fullMatch)) {
|
||||||
errors.addDetailIf(lineNumber, name, match[1]);
|
var wordMatch = fullMatch
|
||||||
|
.replace(/^\W*/, "").replace(/\W*$/, "");
|
||||||
|
if (names.indexOf(wordMatch) === -1) {
|
||||||
|
var lineNumber = token.lineNumber + index + fenceOffset;
|
||||||
|
errors.addDetailIf(lineNumber, name, match[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
16
test/proper-names-projects.json
Normal file
16
test/proper-names-projects.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"default": true,
|
||||||
|
"proper-names": {
|
||||||
|
"names": [
|
||||||
|
"GitHub",
|
||||||
|
"github.com",
|
||||||
|
"github.com/about",
|
||||||
|
"npm",
|
||||||
|
"NPM",
|
||||||
|
"Vue",
|
||||||
|
"Vuex",
|
||||||
|
"vue-router"
|
||||||
|
],
|
||||||
|
"code_blocks": false
|
||||||
|
}
|
||||||
|
}
|
||||||
45
test/proper-names-projects.md
Normal file
45
test/proper-names-projects.md
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Proper Names of Projects (code_blocks:false)
|
||||||
|
|
||||||
|
The site GitHub
|
||||||
|
|
||||||
|
Not github {MD044}
|
||||||
|
|
||||||
|
Link to [GitHub](https://github.com/)
|
||||||
|
|
||||||
|
Link to [github.com](https://github.com/)
|
||||||
|
|
||||||
|
Link to [github.com](https://github.com/about)
|
||||||
|
|
||||||
|
Link to [github.com/about](https://github.com/about)
|
||||||
|
|
||||||
|
The domain name of GitHub is github.com
|
||||||
|
|
||||||
|
The project Vue
|
||||||
|
|
||||||
|
AKA Vue.js
|
||||||
|
|
||||||
|
Not vue {MD044}
|
||||||
|
|
||||||
|
Or vue.js {MD044}
|
||||||
|
|
||||||
|
The file `vue.js` (code block)
|
||||||
|
|
||||||
|
The library Vuex
|
||||||
|
|
||||||
|
Not vuex {MD044}
|
||||||
|
|
||||||
|
The library vue-router
|
||||||
|
|
||||||
|
Not Vue-router {MD044}
|
||||||
|
|
||||||
|
Or vue-router-extra {MD044}
|
||||||
|
|
||||||
|
Or extra-vue-router {MD044}
|
||||||
|
|
||||||
|
Quoted "Vue" and "vue-router"
|
||||||
|
|
||||||
|
Emphasized *Vue* and *vue-router*
|
||||||
|
|
||||||
|
Call it npm
|
||||||
|
Or NPM
|
||||||
|
But not Npm {MD044}
|
||||||
|
|
@ -2,6 +2,12 @@
|
||||||
|
|
||||||
Markdownlint is a tool {MD044}
|
Markdownlint is a tool {MD044}
|
||||||
|
|
||||||
|
Quoted "Markdownlint" {MD044}
|
||||||
|
|
||||||
|
Emphasized *Markdownlint* {MD044}
|
||||||
|
|
||||||
|
Emphasized _Markdownlint_ {MD044}
|
||||||
|
|
||||||
JavaScript is a language
|
JavaScript is a language
|
||||||
|
|
||||||
JavaScript is not Java
|
JavaScript is not Java
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue