textlint rule to enforce AP Style title case for link text and titles in Markdown documents.
- Enforces AP Style title case for link display text, titles, and references
- Handles special terms, acronyms, and technical terminology with proper capitalization
- Supports customization of stop words and special terms
- Provides automatic fixing of improperly cased text
Install with npm:
npm install textlint-rule-link-title-case
Via .textlintrc
(recommended):
{
"rules": {
"link-title-case": true
}
}
With options:
{
"rules": {
"link-title-case": {
"stopWords": ["via", "etc"],
"specialTerms": {
"nextjs": "Next.js",
"nestjs": "Nest.js"
},
"checkLinkTitle": true,
"checkLinkText": true
}
}
}
Via CLI:
textlint --rule link-title-case README.md
checkLinkText
:Boolean
- Default:
true
- Whether to check link display text (
[text](url)
or[text][reference]
)
- Default:
checkLinkTitle
:Boolean
- Default:
true
- Whether to check link titles (
[text](url "title")
or[reference]: url "title"
)
- Default:
specialTerms
:Object
- Default:
{}
- Special terms with custom capitalization (e.g.,
{"nextjs": "Next.js"}
) - In addition of default special terms (see
src/ap-style.js
file)
- Default:
stopWords
:string[]
- Default:
[]
- Additional words to treat as stop words (lowercase in titles unless first/last)
- Default:
[click here to learn about javascript](https://example.com)
[Read More About API design](https://example.com "api design principles")
[reference to github][github-link]
[github-link]: https://github.com "github homepage"
[Click Here to Learn About JavaScript](https://example.com)
[Read More About API Design](https://example.com "API Design Principles")
[Reference to GitHub][github-link]
[github-link]: https://github.com "GitHub Homepage"
Use textlint-filter-rule-comments
to disable terminology check for particular paragraphs:
<!-- textlint-disable link-title-case -->
[Click Here to Learn About JavaScript](https://example.com)
<!-- textlint-enable -->
This rule follows AP Style title case conventions:
- Capitalize the first and last words
- Capitalize all words of four letters or more
- Capitalize nouns, pronouns, adjectives, verbs, adverbs, and subordinating conjunctions
- Lowercase articles (a, an, the), coordinating conjunctions (and, but, or, for, nor), and prepositions of three letters or fewer
- Capitalize a preposition of four or more letters
- Capitalize words following hyphens, colons, em dashes, or other punctuation
- Preserve the capitalization of proper nouns, brand names, and technical terms
textlint-rule-link-title-case
supports the --fix
option.
See https://github.com/textlint/textlint/#fixable for more details.
Install just and run validation tests:
$ just setup
Installing textlint globally...
✅ Project setup complete
$ just validate-all
Building project...
Running tests...
✅ Basic validation complete
Running e2e lint validation...
✅ E2E lint validation passed
Running e2e fix validation...
✅ E2E fix validation passed
✅ Full validation complete