Repository: platers/obsidian-linter (ts)

Issue:
Bug: First letter in Title Case not Uppercase when preceded with numbers or special characters
- [x] I have verified that I am on the latest version of the Linter
Linter version 1.25.0

## Describe the Bug

When having a title like this 
```
135_  A letter arrived
```
It gets formatted as 
```
135 - a Letter Arrived
```

If the letter is in the lowercase words, It will be lowercased even if first letter in the header.

## How to Reproduce

Steps to reproduce the behavior:

1. Make a title similar to mine as the first word is not a letter 
2. Set Capitalize Headings to Title Case
3. Ignore Cased Words to false
4. Lowercase Words should have `a` inside for this example.
5. Format the file
6. See error in the first heading

## Resources
[data.json](https://mega.nz/file/EmoEgTaa#VXhUw8w18oBLbm6AQX9ejvzVvzr8pdm9JpKBcKtHxFY)
[logs.txt](https://mega.nz/file/R3RSmJiA#iR95JHnqZ6sf9b_XEUzTP7dqAqaaRcXGoBZ85y3YXA4)

## Expected Behavior

As the linter run, the header
```
135_  A letter arrived
```
should have been
```
135 - A letter arrived
```

## Device

- [x] Desktop
- [ ] Mobile

## Additional Context

As additional context, take note that I am currently using a regex to modify the header to change `_ ` -> ` - ` as:
`^# (\d+)_ (.+)\n` `gm` `# $1 - $2\n`
As I am not an expert in regexes, maybe this can contribute to the bug.


Pull request description:
Fix ITs Not Running Properly and `'` and `-` Being Considered to be Words and Letters
Fixes #1148 

There was an issue with the Integration tests not running in order all of the time. This was caused by the recent change to loading files in for custom auto-correct files. Fixed it by awaiting the function called in the ITs.

There was also an issue with headers capitalization where `'` and `-` by themselves would be considered words and would cause other issues with capitalization. Checking for these two cases seems to fix the issue.

Patch:
diff --git a/src/rules/capitalize-headings.ts b/src/rules/capitalize-headings.ts
index 9773f22..16ee504 100644
--- a/src/rules/capitalize-headings.ts
+++ b/src/rules/capitalize-headings.ts
@@ -425,7 +425,7 @@ export default class CapitalizeHeadings extends RuleBuilder<CapitalizeHeadingsOp
       for (let j = 1; j < headerWords.length; j++) {
         // based on https://stackoverflow.com/a/62032796 "/\p{L}/u" accounts for all unicode letters across languages
         const isWord = headerWords[j].match(/^[\p{L}'-]{1,}[.?!,:;\d]*$/u);
-        if (!isWord) {
+        if (!isWord || headerWords[j] === '-' || headerWords[j] === '\'') {
           continue;
         }
 


Test patch:
diff --git a/__integration__/main.test.ts b/__integration__/main.test.ts
index 4f822a0..177974c 100644
--- a/__integration__/main.test.ts
+++ b/__integration__/main.test.ts
@@ -60,7 +60,7 @@ export default class TestLinterPlugin extends Plugin {
           await t.setup(this, activeLeaf.editor);
         }
 
-        this.plugin.runLinterEditor(activeLeaf.editor);
+        await this.plugin.runLinterEditor(activeLeaf.editor);
         await t.assertions(activeLeaf.editor);
 
         console.log('✅', t.name);
@@ -133,7 +133,7 @@ export default class TestLinterPlugin extends Plugin {
         await t.setup(this, activeLeaf.editor);
       }
 
-      testPlugin.plugin.runLinterEditor(activeLeaf.editor);
+      await testPlugin.plugin.runLinterEditor(activeLeaf.editor);
     } catch (e) {
       console.log('❌', t.name);
       console.error(e);
diff --git a/__tests__/capitalize-headings.test.ts b/__tests__/capitalize-headings.test.ts
index c812f09..ef4a0c2 100644
--- a/__tests__/capitalize-headings.test.ts
+++ b/__tests__/capitalize-headings.test.ts
@@ -194,5 +194,19 @@ ruleTest({
         style: 'ALL CAPS',
       },
     },
+    { // accounts for https://github.com/platers/obsidian-linter/issues/1148
+      testName: `Make sure that a header with a dash or single quote as an entry before the first letter get skipped as the first letter`,
+      before: dedent`
+        # 135 - a Letter Arrived
+        # 135 ' a Letter Arrived
+      `,
+      after: dedent`
+        # 135 - A Letter Arrived
+        # 135 ' A Letter Arrived
+      `,
+      options: {
+        style: 'First letter',
+      },
+    },
   ],
 });