mdrefine 0.2.0 → 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
@@ -761,6 +767,13 @@ so are the exceptions of [Forgejo and Gitea](dialects.md#forgejo-and-gitea):
761
767
  the dollar decides whether dollar math ends there.
762
768
  - Emphasis that begins on the line of an alert's or a callout's marker and ends
763
769
  below it.
770
+ - Emphasis whose text holds a run of tildes that could mark strikethrough, one
771
+ or two tildes or in Obsidian two, while the paragraph holds another: GitHub
772
+ can read strikethrough there and the markers as text.
773
+ - A `_`, old or new, that only tildes separate from a letter or digit, as in
774
+ `x~~_b_~~`, which GitHub reads as inside a word.
775
+ - Text whose markers CommonMark pairs otherwise than the parser, as in
776
+ `xab***a* a*y`: GitHub follows CommonMark, so the parser misread the text.
764
777
 
765
778
  ## `style/final-newline`
766
779
 
@@ -814,9 +827,11 @@ After:
814
827
 
815
828
  A trailing run of `#` in the text of an underlined heading is escaped, so that
816
829
  it is not taken for a closing sequence. Underlined headings of more than one
817
- line, and those inside lists or block quotes, are left as written. On Forgejo
818
- and Gitea, a closing sequence after an attribute block such as `{#id}` stays,
819
- 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.
820
835
 
821
836
  With `setext`, a `#` heading is underlined only where its text can stand on a
822
837
  line of its own as the same heading: at the start of a line of the document, not
@@ -852,6 +867,9 @@ joined line would read differently:
852
867
  marker, which holds an Obsidian callout's title.
853
868
  - Where the joined span needs a different number of backticks than it has, and
854
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.
855
873
 
856
874
  Before:
857
875
 
@@ -934,6 +952,17 @@ These are left as written:
934
952
  another block once inside the item.
935
953
  - A list with a tab in an item's indentation, such as one that Obsidian indented
936
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.
937
966
 
938
967
  ## `style/list-marker`
939
968
 
@@ -956,7 +985,9 @@ A bullet list that directly follows another one is a separate list only because
956
985
  its marker differs, so it gets the next marker in the order `-`, `*`, `+`, and
957
986
  the list after that the first one again. A list whose new marker would make a
958
987
  line read as a thematic break, as `+ - -` would with `-`, keeps its markers, and
959
- 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).
960
991
 
961
992
  Before:
962
993
 
@@ -1003,7 +1034,9 @@ number gets wider or narrower, as from `9.` to `10.`, the item's other lines
1003
1034
  move with its text. A list keeps its numbers where that would move a line into
1004
1035
  or out of an item, as for [`style/list-indent`](#stylelist-indent), and where
1005
1036
  the numbers are written with leading zeros, as in `01.`, or would need more than
1006
- 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`.
1007
1040
 
1008
1041
  Before:
1009
1042
 
@@ -1098,8 +1131,9 @@ Text.
1098
1131
  A break is left as written where the new marker would change what the document
1099
1132
  means:
1100
1133
 
1101
- - With `---`, directly below a paragraph or a link reference definition, which
1102
- `---` 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.
1103
1137
  - On the line of a list item whose marker is the new marker's character, as in
1104
1138
  `- ***` with `---`: `- ---` is one thematic break, not a list item.
1105
1139
  - At the start of a document, with `---`, which would open front matter if a
@@ -1107,6 +1141,10 @@ means:
1107
1141
  start of front matter.
1108
1142
  - With `---`, at the start of a line below a first line of `---` that no line
1109
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).
1110
1148
 
1111
1149
  ## `style/trailing-space`
1112
1150
 
@@ -1154,10 +1192,12 @@ span, an image, math, a link's destination, a template tag on one line such as
1154
1192
  `{% data x %}` or `{{ title }}`, and a word longer than the line stay whole and
1155
1193
  can overflow; a code span or an image description written across lines is joined
1156
1194
  onto one, without the spaces and tabs that start its next line, as renderers
1157
- read it. In Obsidian, the text of a link stays whole and is joined onto one line
1158
- too, because Live Preview shows a link whose text spans lines as its Markdown
1159
- source. List markers, block quote markers, and indentation count toward the
1160
- 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.
1161
1201
 
1162
1202
  A word that would start a block at the start of a line, such as a list marker,
1163
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.0",
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",