Repository: platers/obsidian-linter (ts)

Issue:
FR: Capitalize Headings, The words in the Lowercase words list to be Uppercase when it is the first letter
I want to request that for the function of `Capitalize Headings`, the words listed in `the Lowercase Words` better be uppercase when it is the first letter.

For example:
## the Best of the Best 

should be
## The Best of the Best

Thanks!

Pull request description:
Fix Title Case Style Not Capitalizing the First Word
Fixes #171 

Takes care of title case first word capitalization when the first set of characters is not a word.

Changes Made:
- Made sure to not assume the first set of characters would be a word
- Added another header to the title case test case string

Patch:
diff --git a/src/rules.ts b/src/rules.ts
index 81dd85c..2939e21 100644
--- a/src/rules.ts
+++ b/src/rules.ts
@@ -1103,6 +1103,7 @@ export const rules: Rule[] = [
                 const ignoreShortWords = (
                 options['Lowercase Words'] as string
                 ).split(/[,\s]+/);
+                let firstWord = true;
                 for (let j = 1; j < headerWords.length; j++) {
                   const isWord = headerWords[j].match(/^[A-Za-z'-]+[.?!,:;]?$/);
                   if (!isWord) {
@@ -1117,12 +1118,14 @@ export const rules: Rule[] = [
                   if (!keepWordCasing) {
                     headerWords[j] = headerWords[j].toLowerCase();
                     const ignoreWord = ignoreShortWords.includes(headerWords[j]);
-                    if (!ignoreWord || j == 1) {
+                    if (!ignoreWord || firstWord === true) {
                     // ignore words that are not capitalized in titles except if they are the first word
                       headerWords[j] =
                       headerWords[j][0].toUpperCase() + headerWords[j].slice(1);
                     }
                   }
+
+                  firstWord = false;
                 }
 
                 lines[i] = lines[i].replace(


Test patch:
diff --git a/src/test.ts b/src/test.ts
index f29c898..9849979 100644
--- a/src/test.ts
+++ b/src/test.ts
@@ -166,6 +166,7 @@ describe('Rules tests', () => {
         ## this is a sentence.
         ## I can't do this
         ## comma, comma, comma
+        ## 1.1 the Header
         `;
       const after = dedent`
         # h1
@@ -173,6 +174,7 @@ describe('Rules tests', () => {
         ## This is a Sentence.
         ## I Can't Do This
         ## Comma, Comma, Comma
+        ## 1.1 The Header
         `;
       const options = Object.assign({
         'Style': 'Title Case',