mdrefine 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/rules.md CHANGED
@@ -4,7 +4,8 @@ A rule is either a **style** rule or a **problem** rule. A style rule checks how
4
4
  something is written and proposes an edit, which `format` applies and `lint`
5
5
  reports. A problem rule reports a defect that has no single correct repair, and
6
6
  never edits. `format` applies an edit only when the document still means the
7
- same afterwards; see [how it works](design.md#safety-model).
7
+ same afterwards, and never in text that the parser reads where renderers read a
8
+ list; see [how it works](design.md#safety-model).
8
9
 
9
10
  Enable and configure rules under `rules` in the
10
11
  [configuration](configuration.md#rules-and-severity). `npx mdtools rules` lists
@@ -165,7 +166,9 @@ Writes the type of a GitHub alert in capitals. The renderers accept any case for
165
166
  the five types `NOTE`, `TIP`, `IMPORTANT`, `WARNING`, and `CAUTION`, and their
166
167
  documentation spells them in capitals. Other types are not alerts there and are
167
168
  left as written, and so is a marker written with an escape or a character
168
- reference, such as `\[!note]`.
169
+ reference, such as `\[!note]`. So is a marker that GitHub shows as text: one in
170
+ a block quote inside another quote or a list, one followed by text on its line,
171
+ and one with nothing below it in the quote.
169
172
 
170
173
  Before:
171
174
 
@@ -682,10 +685,13 @@ or what a comment applies to:
682
685
  - In the Obsidian dialect, a block identifier on a line of its own (`^id`)
683
686
  directly below a heading or list, which Obsidian may attach to the block
684
687
  above.
685
- - Directly below text or a link reference definition: a list or quote whose
686
- first line continues with another list marker, as in `- 2. Step` or `- -`, and
687
- a heading underlined with `===` or `---`. The parser can read such a line
688
- differently there than below a blank line.
688
+ - Directly below text or a link reference definition: a heading underlined with
689
+ `===` or `---`, which the parser can read differently there than below a blank
690
+ line.
691
+ - Text that the parser reads where renderers read a list, such as `- 2. Step`
692
+ directly below text: the list or quote that starts with it, the blocks
693
+ indented below it, and a list after them, which renderers read as part of that
694
+ list (see [how it works](design.md#safety-model)).
689
695
  - Directly below a table that ends in a list item or block quote: text whose
690
696
  second line is a table delimiter row. The parser reads a table there as text,
691
697
  where GitHub reads a table, and a blank line would make it a table for the
@@ -821,9 +827,11 @@ After:
821
827
 
822
828
  A trailing run of `#` in the text of an underlined heading is escaped, so that
823
829
  it is not taken for a closing sequence. Underlined headings of more than one
824
- line, and those inside lists or block quotes, are left as written. On Forgejo
825
- and Gitea, a closing sequence after an attribute block such as `{#id}` stays,
826
- because Gitea before 1.26 reads the block only when the sequence follows it.
830
+ line, those inside lists or block quotes, and one directly below TOML front
831
+ matter, whose lines renderers without TOML front matter read as part of the
832
+ heading, are left as written. On Forgejo and Gitea, a closing sequence after an
833
+ attribute block such as `{#id}` stays, because Gitea before 1.26 reads the block
834
+ only when the sequence follows it.
827
835
 
828
836
  With `setext`, a `#` heading is underlined only where its text can stand on a
829
837
  line of its own as the same heading: at the start of a line of the document, not
@@ -859,6 +867,9 @@ joined line would read differently:
859
867
  marker, which holds an Obsidian callout's title.
860
868
  - Where the joined span needs a different number of backticks than it has, and
861
869
  an earlier run of that many in the same paragraph would pair with them.
870
+ - Where a line inside the span ends with a backslash: where its backticks do not
871
+ pair, as on GitHub after an unpaired longer run, that backslash is a hard line
872
+ break. `style/wrap` keeps such a paragraph as written too.
862
873
 
863
874
  Before:
864
875
 
@@ -941,6 +952,17 @@ These are left as written:
941
952
  another block once inside the item.
942
953
  - A list with a tab in an item's indentation, such as one that Obsidian indented
943
954
  with tabs.
955
+ - A list directly below TOML front matter that cannot interrupt a paragraph: a
956
+ numbered list that does not start at 1, or one whose first item starts with a
957
+ blank line, and the lists that directly follow it. Renderers without TOML
958
+ front matter read the front matter's lines as a paragraph, which such a list
959
+ continues as text. `style/list-marker` and `style/ordered-list` leave these
960
+ lists as written too.
961
+ - A list among the blocks indented below text that the parser reads where
962
+ renderers read a list, such as `2. Two` after an indented code block, or the
963
+ list right after them, and the lists next to it (see [how it
964
+ works](design.md#safety-model)). `style/list-marker` and `style/ordered-list`
965
+ keep their markers too.
944
966
 
945
967
  ## `style/list-marker`
946
968
 
@@ -963,7 +985,9 @@ A bullet list that directly follows another one is a separate list only because
963
985
  its marker differs, so it gets the next marker in the order `-`, `*`, `+`, and
964
986
  the list after that the first one again. A list whose new marker would make a
965
987
  line read as a thematic break, as `+ - -` would with `-`, keeps its markers, and
966
- so do the lists next to it.
988
+ so do the lists next to it. So does a list directly below TOML front matter
989
+ whose first item starts with a blank line, as for
990
+ [`style/list-indent`](#stylelist-indent).
967
991
 
968
992
  Before:
969
993
 
@@ -1010,7 +1034,9 @@ number gets wider or narrower, as from `9.` to `10.`, the item's other lines
1010
1034
  move with its text. A list keeps its numbers where that would move a line into
1011
1035
  or out of an item, as for [`style/list-indent`](#stylelist-indent), and where
1012
1036
  the numbers are written with leading zeros, as in `01.`, or would need more than
1013
- nine digits.
1037
+ nine digits. A list directly below TOML front matter that does not start at 1,
1038
+ or whose first item starts with a blank line, keeps its delimiter and numbers,
1039
+ as for `style/list-indent`.
1014
1040
 
1015
1041
  Before:
1016
1042
 
@@ -1105,8 +1131,9 @@ Text.
1105
1131
  A break is left as written where the new marker would change what the document
1106
1132
  means:
1107
1133
 
1108
- - With `---`, directly below a paragraph or a link reference definition, which
1109
- `---` would underline as a heading.
1134
+ - With `---`, directly below a paragraph, a link reference definition, or
1135
+ display math, which `---` would underline as a heading; GitHub builds display
1136
+ math from a paragraph.
1110
1137
  - On the line of a list item whose marker is the new marker's character, as in
1111
1138
  `- ***` with `---`: `- ---` is one thematic break, not a list item.
1112
1139
  - At the start of a document, with `---`, which would open front matter if a
@@ -1114,6 +1141,10 @@ means:
1114
1141
  start of front matter.
1115
1142
  - With `---`, at the start of a line below a first line of `---` that no line
1116
1143
  closes, which `---` would close as front matter.
1144
+ - Directly below TOML front matter, a break that is or would become `---`,
1145
+ because renderers without TOML front matter read the front matter's lines as a
1146
+ paragraph that `---` underlines as a heading; see the [safety
1147
+ model](design.md#safety-model).
1117
1148
 
1118
1149
  ## `style/trailing-space`
1119
1150
 
@@ -1161,10 +1192,12 @@ span, an image, math, a link's destination, a template tag on one line such as
1161
1192
  `{% data x %}` or `{{ title }}`, and a word longer than the line stay whole and
1162
1193
  can overflow; a code span or an image description written across lines is joined
1163
1194
  onto one, without the spaces and tabs that start its next line, as renderers
1164
- read it. In Obsidian, the text of a link stays whole and is joined onto one line
1165
- too, because Live Preview shows a link whose text spans lines as its Markdown
1166
- source. List markers, block quote markers, and indentation count toward the
1167
- width, a tab up to the next multiple of four columns.
1195
+ read it. On a lazy continuation line, which keeps them, such a code span stays
1196
+ as written, and so does its paragraph. In Obsidian, the text of a link stays
1197
+ whole and is joined onto one line too, because Live Preview shows a link whose
1198
+ text spans lines as its Markdown source. List markers, block quote markers, and
1199
+ indentation count toward the width, a tab up to the next multiple of four
1200
+ columns.
1168
1201
 
1169
1202
  A word that would start a block at the start of a line, such as a list marker,
1170
1203
  `#`, `>`, a run of `-` or `=`, or a table delimiter row such as `|---|`, stays
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdrefine",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Configurable Markdown linting and formatting for CommonMark, GitHub, Forgejo, Gitea, and Obsidian",
5
5
  "keywords": [
6
6
  "markdown",
@@ -120,10 +120,13 @@
120
120
  },
121
121
  "devDependencies": {
122
122
  "@eslint/js": "10.0.1",
123
+ "@types/commonmark": "0.27.10",
123
124
  "@types/node": "22.20.5",
124
125
  "@types/unist": "3.0.3",
126
+ "commonmark": "0.31.2",
125
127
  "eslint": "10.13.0",
126
128
  "fast-check": "4.10.2",
129
+ "markdown-it": "15.0.3",
127
130
  "npm-run-all2": "9.0.3",
128
131
  "prettier": "3.9.10",
129
132
  "typescript": "6.0.3",