Repository: platers/obsidian-linter (ts)

Issue:
Bug: `Remove Empty List Markers` rule removes number if it's the only content in the line
## Describe the Bug

`Remove Empty List Markers` rule removes number if it's the only content in the line

## How to Reproduce

Consider note

``` markdown
# World War II

1939
```

And run  `Remove Empty List Markers` rule.

## Expected Behavior

The note is not changed

## Actual Behavior

`1939` is trimmed from the note as it was mistakenly considered to be a list marker, which is weird, because it is not followed by a dot `.`

Pull request description:
RemoveEmptyListMarkers fix for single number
Fixes #405 

Patch:
diff --git a/src/rules/remove-empty-list-markers.ts b/src/rules/remove-empty-list-markers.ts
index 4675b46..26543f6 100644
--- a/src/rules/remove-empty-list-markers.ts
+++ b/src/rules/remove-empty-list-markers.ts
@@ -22,7 +22,7 @@ export default class RemoveEmptyListMarkers extends RuleBuilder<RemoveEmptyListM
   }
   apply(text: string, options: RemoveEmptyListMarkersOptions): string {
     return ignoreListOfTypes([IgnoreTypes.code, IgnoreTypes.yaml, IgnoreTypes.link, IgnoreTypes.wikiLink, IgnoreTypes.tag], text, (text) => {
-      const emptyListMarkerRegex = /^\s*(>\s*)*(-|\*|\+|\d+.|- (\[( |x)\]))\s*?$/gm;
+      const emptyListMarkerRegex = /^\s*(>\s*)*(-|\*|\+|\d+[.)]|- (\[( |x)\]))\s*?$/gm;
       // remove all empty list markers followed by a new line
       text = text.replace(new RegExp(emptyListMarkerRegex.source + '\\n', 'gm'), '');
       // remove all empty list markers proceeded by a new line


Test patch:
diff --git a/__tests__/remove-empty-list-markers.test.ts b/__tests__/remove-empty-list-markers.test.ts
index 4bab0b0..4570a54 100644
--- a/__tests__/remove-empty-list-markers.test.ts
+++ b/__tests__/remove-empty-list-markers.test.ts
@@ -24,5 +24,41 @@ ruleTest({
         ${''}
       `,
     },
+    {
+      testName: 'Don\'t remove number if it is the only content of the line',
+      before: dedent`
+        42
+      `,
+      after: dedent`
+        42
+      `,
+    },
+    {
+      testName: 'Don\'t remove number if not followed by `.` or `)`',
+      before: dedent`
+        42z
+      `,
+      after: dedent`
+        42z
+      `,
+    },
+    {
+      testName: 'Remove number followed by `.`',
+      before: dedent`
+        42.
+      `,
+      after: dedent`
+        ${''}
+      `,
+    },
+    {
+      testName: 'Remove number followed by `)`',
+      before: dedent`
+        42)
+      `,
+      after: dedent`
+        ${''}
+      `,
+    },
   ],
 });