Skip to content

Commit ecea8e2

Browse files
committed
Breaking: bump remark and plugins
Changes a few escape sequences: - `<` and `>` are no longer escaped as HTML entities - Underscores if not used for emphasis, are escaped with a backslash - Ampersands in URLs are escaped with a backslash. - Square brackets if not used for definitions (links) are escaped. Added one new rule that is a breaking change: thematic breaks must be `---` rather than `***` or `* * *` or `- - -`. Ref #80
1 parent 175055a commit ecea8e2

8 files changed

Lines changed: 79 additions & 31 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
version: 2
22
updates:
3-
# Disabled until we migrate to remark 13
4-
# - package-ecosystem: npm
5-
# directory: /
6-
# schedule:
7-
# interval: monthly
3+
- package-ecosystem: npm
4+
directory: /
5+
schedule:
6+
interval: monthly
87
- package-ecosystem: github-actions
98
directory: /
109
schedule:

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,15 @@ README.md:5:3
109109

110110
## Rules
111111

112-
- [Insert links to GitHub issues, PRs and usernames](https://www.npmjs.com/package/remark-github) (not linted yet)
112+
- [Use `-` as marker for bullets of items in unordered lists](https://www.npmjs.com/package/remark-lint-unordered-list-marker-style) (`- item`)
113+
- [Use `_` as marker for emphasis](https://www.npmjs.com/package/remark-lint-emphasis-marker) (`_emphasis_`)
114+
- [Use `*` as marker for strong](https://www.npmjs.com/package/remark-lint-strong-marker) (`**strong**`)
115+
- [Use `x` as marker for checkboxes](https://www.npmjs.com/package/remark-lint-checkbox-character-style) (`- [x] item`)
116+
- [Use backtick as marker for fenced code block](https://www.npmjs.com/package/remark-lint-fenced-code-marker)
117+
- [Always use fences for code blocks](https://www.npmjs.com/package/remark-lint-code-block-style)
118+
- [Use `---` for thematic breaks](https://www.npmjs.com/package/remark-lint-rule-style)
119+
- [Insert links to GitHub issues, PRs and usernames](https://www.npmjs.com/package/remark-github) (not linted)
113120
- [Collapse a Table of Contents if it exists](https://www.npmjs.com/package/remark-collapse) (not linted)
114-
- [Fenced code blocks](https://www.npmjs.com/package/remark-lint-code-block-style)
115121
- [End file with newline](https://www.npmjs.com/package/remark-lint-final-newline)
116122
- No dead links, references and definitions:
117123
- [No dead internal links](https://www.npmjs.com/package/remark-validate-links)
@@ -131,9 +137,9 @@ README.md:5:3
131137
- [No literal URLs without angle-brackets](https://www.npmjs.com/package/remark-lint-no-literal-urls)
132138
- [No angle-bracketed links (`<url>`) without protocol](https://www.npmjs.com/package/remark-lint-no-auto-link-without-protocol)
133139
- [No blank lines without markers (`>`) in a blockquote](https://www.npmjs.com/package/remark-lint-no-blockquote-without-marker)
134-
- [Table cells must be padded](https://www.npmjs.com/package/remark-lint-table-cell-padding) ([#16](https://github.com/vweevers/hallmark/issues/16))
135-
- [Table rows must be fenced with pipes](https://www.npmjs.com/package/remark-lint-table-pipes)
136-
- [Checkboxes must use `x` as marker](https://www.npmjs.com/package/remark-lint-checkbox-character-style)
140+
- Tables:
141+
- [Table cells must be padded](https://www.npmjs.com/package/remark-lint-table-cell-padding) ([#16](https://github.com/vweevers/hallmark/issues/16))
142+
- [Table rows must be fenced with pipes](https://www.npmjs.com/package/remark-lint-table-pipes)
137143

138144
## Usage
139145

index.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { engine } from 'unified-engine'
55
import supportsColor from 'supports-color'
66
import { fromCallback } from 'catering'
77
import defaultReporter from 'vfile-reporter-shiny'
8-
import processor from 'remark'
8+
import { remark as processor } from 'remark'
9+
import remarkGfm from 'remark-gfm'
910
import remarkCommonChangelog from 'remark-common-changelog'
1011
import remarkGithub from 'remark-github'
1112
import remarkAutolinkReferences from 'remark-autolink-references'
@@ -78,6 +79,15 @@ function hallmark (options, callback) {
7879
reporter,
7980
reporterOptions,
8081
plugins: [
82+
[remarkGfm, {
83+
tableCellPadding: true,
84+
85+
// Allow disabling padding because on big tables it creates noise.
86+
tablePipeAlign: paddedTable,
87+
88+
// In addition, use fixed width columns. TODO: use string-width package
89+
stringLength: paddedTable ? (s) => String(s).length : () => 3
90+
}],
8191
[remarkCommonChangelog, { cwd, fix, pkg, repository, ...changelog }],
8292
[remarkGithub, { repository }],
8393

@@ -100,13 +110,21 @@ function hallmark (options, callback) {
100110
settings: {
101111
// One style for code blocks, whether they have a language or not.
102112
fences: true,
103-
listItemIndent: '1',
104113

105-
// Allow disabling padding because on big tables it creates noise.
106-
tablePipeAlign: paddedTable,
114+
// Whether to indent the content of list items with the size of the bullet plus one space
115+
listItemIndent: 'one',
116+
117+
// Marker to use for bullets of items in unordered lists
118+
bullet: '-',
119+
120+
// Marker to use for thematic breaks
121+
rule: '-',
122+
123+
// Marker to use to serialize emphasis
124+
emphasis: '_',
107125

108-
// In addition, use fixed width columns.
109-
stringLength: paddedTable ? (s) => String(s).length : () => 3
126+
// Marker to use to serialize strong
127+
strong: '*'
110128
},
111129
pluginPrefix: 'remark',
112130
// "Whether to write successfully processed files"

lint.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ import remarkLintTablePipes from 'remark-lint-table-pipes'
1919
import remarkLintCheckboxCharacterStyle from 'remark-lint-checkbox-character-style'
2020
import remarkLintDefinitionCase from 'remark-lint-definition-case'
2121
import remarkValidateLinks from 'remark-validate-links'
22+
import remarkLintEmphasisMarker from 'remark-lint-emphasis-marker'
23+
import remarkLintStrongMarker from 'remark-lint-strong-marker'
24+
import remarkLintUnorderedListMarkerStyle from 'remark-lint-unordered-list-marker-style'
25+
import remarkLintFencedCodeMarker from 'remark-lint-fenced-code-marker'
26+
import remarkLintRuleStyle from 'remark-lint-rule-style'
2227

2328
export default function ({ fix, repository, paddedTable, validateLinks }) {
2429
const preset = {
@@ -41,9 +46,14 @@ export default function ({ fix, repository, paddedTable, validateLinks }) {
4146

4247
if (!fix) {
4348
preset.plugins.push(
49+
[remarkLintEmphasisMarker, '_'],
50+
[remarkLintStrongMarker, '*'],
4451
remarkLintFinalNewline,
52+
[remarkLintUnorderedListMarkerStyle, '-'],
4553
remarkLintListItemBulletIndent,
4654
[remarkLintListItemIndent, 'space'],
55+
[remarkLintFencedCodeMarker, '`'],
56+
[remarkLintRuleStyle, '---'],
4757
remarkLintNoAutoLinkWithoutProtocol,
4858
remarkLintNoBlockquoteWithoutMarker,
4959
remarkLintNoLiteralUrls,

package.json

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,37 @@
2525
"deglob": "^4.0.0",
2626
"find-file-up": "^2.0.1",
2727
"find-githost": "^1.0.0",
28-
"remark": "^12.0.1",
29-
"remark-autolink-references": "^1.0.0",
28+
"remark": "^14.0.1",
29+
"remark-autolink-references": "^2.0.0",
3030
"remark-collapse": "~0.1.2",
3131
"remark-common-changelog": "^0.0.3",
32-
"remark-github": "^9.0.1",
33-
"remark-lint": "^7.0.1",
32+
"remark-gfm": "^3.0.1",
33+
"remark-github": "^11.2.1",
34+
"remark-lint": "^9.1.0",
3435
"remark-lint-blockquote-indentation": "^3.1.0",
35-
"remark-lint-checkbox-character-style": "^2.0.1",
36-
"remark-lint-checkbox-content-indent": "^2.0.1",
36+
"remark-lint-checkbox-character-style": "^4.1.0",
37+
"remark-lint-checkbox-content-indent": "^4.1.0",
3738
"remark-lint-code-block-style": "^3.1.0",
3839
"remark-lint-definition-case": "^3.1.0",
40+
"remark-lint-emphasis-marker": "^3.1.0",
41+
"remark-lint-fenced-code-marker": "^3.1.0",
3942
"remark-lint-final-newline": "^2.1.0",
4043
"remark-lint-hard-break-spaces": "^3.1.0",
41-
"remark-lint-list-item-bullet-indent": "^2.0.1",
44+
"remark-lint-list-item-bullet-indent": "^4.1.0",
4245
"remark-lint-list-item-indent": "^3.1.0",
4346
"remark-lint-no-auto-link-without-protocol": "^3.1.0",
44-
"remark-lint-no-blockquote-without-marker": "^3.0.1",
47+
"remark-lint-no-blockquote-without-marker": "^5.1.0",
4548
"remark-lint-no-duplicate-definitions": "^3.1.0",
46-
"remark-lint-no-heading-content-indent": "^2.0.1",
47-
"remark-lint-no-inline-padding": "^2.0.1",
49+
"remark-lint-no-heading-content-indent": "^4.1.0",
50+
"remark-lint-no-inline-padding": "^4.1.0",
4851
"remark-lint-no-literal-urls": "^3.1.0",
49-
"remark-lint-no-undefined-references": "^2.0.1",
52+
"remark-lint-no-undefined-references": "^4.1.0",
5053
"remark-lint-no-unused-definitions": "^3.1.0",
51-
"remark-lint-table-cell-padding": "^2.0.1",
52-
"remark-lint-table-pipes": "^2.0.1",
54+
"remark-lint-rule-style": "^3.1.0",
55+
"remark-lint-strong-marker": "^3.1.0",
56+
"remark-lint-table-cell-padding": "^4.1.1",
57+
"remark-lint-table-pipes": "^4.1.0",
58+
"remark-lint-unordered-list-marker-style": "^3.1.0",
5359
"remark-toc": "^8.0.1",
5460
"remark-validate-links": "^11.0.2",
5561
"subarg": "^1.0.0",

test/api.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ test('lints various', function (t) {
1010
t.ifError(err)
1111
t.is(actual, expected)
1212
t.same(file.messages.map(String), [
13+
'test.md:3:1-3:10: Marker style should be `-`',
14+
'test.md:4:1-4:8: Marker style should be `-`',
15+
'test.md:5:1-5:6: Marker style should be `-`',
1316
'test.md:5:3-5:6: Found reference to undefined definition',
17+
'test.md:6:1-6:21: Marker style should be `-`',
1418
'test.md:6:3-6:21: Don’t use literal URLs without angle brackets',
1519
'test.md:12:23: Cell should be padded',
1620
'test.md:16:1-16:9: Code blocks should be fenced',
17-
'test.md:28:4-28:5: Checked checkboxes should use `x` as a marker'
21+
'test.md:28:5: Checked checkboxes should use `x` as a marker',
22+
'test.md:32:1-32:6: Rules should use `---`'
1823
])
1924
t.end()
2025
})

test/fixture/00-various-input.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ yes()
2828
- [X] no
2929
- [x] yes
3030
- [ ] foo
31+
32+
* * *

test/fixture/00-various-output.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- a [**@user**](https://github.com/user)
44
- b [#12](https://github.com/test/test/issues/12)
5-
- [c]
5+
- \[c]
66
- <http://example.com>
77

88
## table
@@ -30,3 +30,5 @@ yes()
3030
- [x] no
3131
- [x] yes
3232
- [ ] foo
33+
34+
---

0 commit comments

Comments
 (0)