You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(md018): recognize tags that start with a digit
Obsidian's rule is that a tag must contain at least one non-numerical
character, wherever it sits: #1984 is not a tag, #y1984 and #3d_printing
are. The tag pattern instead required the character right after # to be a
non-digit, so every digit-leading tag was read as a malformed heading.
Under the Obsidian flavor, where tags default to on, this was not just a
spurious warning: rumdl fmt rewrote #3d_printing into a heading, and MD025
then demoted the duplicate H1, so a tag became "## 3d_printing".
A leading digit run is now allowed when a letter, combining mark, emoji,
underscore, hyphen or slash follows it. Punctuation deliberately does not
count, so #37. and #42, stay issue references rather than becoming tags.
The change only adds exemptions, so nothing exempt before is now flagged.
Two tests asserted the old behavior, listing #1tag and #2023-project as
invalid tags, and the sibling loop over valid tags discarded its result
without asserting. Both are corrected.
Closes#799
Copy file name to clipboardExpand all lines: docs/md018.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,9 @@ This rule correctly handles:
107
107
108
108
When `tags = true`, this rule skips `#word` patterns that look like tags (e.g., `#todo`, `#project/active`) instead of treating them as malformed headings.
109
109
110
-
Tags are recognized when they start with `#` followed by a non-digit, non-space character. Multi-hash patterns like `##tag` are always treated as malformed headings, and `#123` (starting with a digit) is not a valid tag.
110
+
Tags are recognized following [Obsidian's tag rules](https://obsidian.md/help/tags): a tag must contain at least one non-numerical character, so `#1984` is not a tag but `#y1984` and `#3d_printing` are. Multi-hash patterns like `##tag` are always treated as malformed headings.
111
+
112
+
A leading run of digits is allowed as long as a letter, an underscore, a hyphen, a forward slash or an emoji follows it. Digits followed by other punctuation stay flagged, because `#37.` and `#42,` are issue references rather than tags.
111
113
112
114
When `tags` is not explicitly set, it defaults to `true` for Obsidian flavor and `false` otherwise. This means Obsidian users get tag support automatically, while users of other flavors can opt in:
113
115
@@ -127,16 +129,18 @@ tags = true
127
129
128
130
#project/active nested tag
129
131
132
+
#3d_printing tag starting with a digit
133
+
130
134
##Introduction
131
135
```
132
136
133
137
<!-- rumdl-enable MD018 MD022 MD025 -->
134
138
135
139
With `tags = true`:
136
140
137
-
-`#todo` and `#project/active` are **not flagged** (recognized as tags)
141
+
-`#todo`, `#project/active` and `#3d_printing` are **not flagged** (recognized as tags)
138
142
-`##Introduction` is **flagged** (multi-hash, clearly a malformed heading)
139
-
-`#123` is **flagged** (tags cannot start with digits)
143
+
-`#1984` is **flagged** (all-numeric, so not a valid tag)
0 commit comments