Repository: platers/obsidian-linter (ts)

Issue:
Bug: Unexpected blank line.
``` markdown
### 調査企画書 BEFORE

**【状況理解（背景）】**
  - 事業上どのような課題があるのか
  - 調査結果からどのようなアクションをしたいのか  
**【問い（目的）】**
  - 何を明らかにするのか  
**【対象】**
  - どのような人を対象にするか  
```

``` markdown
### 調査企画書 AFTER

**【状況理解（背景）】**

  - 事業上どのような課題があるのか
  - 調査結果からどのようなアクションをしたいのか  
**【問い（目的）】**
  - 何を明らかにするのか  
**【対象】**
  - どのような人を対象にするか  
```

A blank line will be inserted after row 3 (【状況理解（背景）】).
Prettier won't add it.

And if you need the settings, please let me know which file contains it.

Pull request:
Fix Table Matching Logic and Add Paragraph Blank Lines Example
Fixes #704 

Changes Made:
- Added UTs for paragraph blank lines and table matching for the scenario with an empty list item proceeded by a blank line
- Updated table recognition of invalid tables to be more generic just checking that the first or second line of the table has a pipe in it otherwise it cannot be a table

Patch:
diff --git a/src/rules/paragraph-blank-lines.ts b/src/rules/paragraph-blank-lines.ts
index a003a9f..d02ccaa 100644
--- a/src/rules/paragraph-blank-lines.ts
+++ b/src/rules/paragraph-blank-lines.ts
@@ -38,6 +38,30 @@ export default class ParagraphBlankLines extends RuleBuilder<ParagraphBlankLines
           A paragraph is a line that starts with a letter.
         `,
       }),
+      new ExampleBuilder({
+        description: 'Paragraphs can be extended via the use of 2 or more spaces at the end of a line or line break html',
+        before: dedent`
+          # H1
+          Content${'  '}
+          Paragraph content continued <br>
+          Paragraph content continued once more <br/>
+          Last line of paragraph
+          A new paragraph
+          # H2
+        `,
+        after: dedent`
+          # H1
+          ${''}
+          Content${'  '}
+          Paragraph content continued <br>
+          Paragraph content continued once more <br/>
+          Last line of paragraph
+          ${''}
+          A new paragraph
+          ${''}
+          # H2
+        `,
+      }),
     ];
   }
   get optionBuilders(): OptionBuilderBase<ParagraphBlankLinesOptions>[] {
diff --git a/src/utils/mdast.ts b/src/utils/mdast.ts
index 6ae82ad..e8343d7 100644
--- a/src/utils/mdast.ts
+++ b/src/utils/mdast.ts
@@ -769,9 +769,8 @@ export function getAllTablesInText(text: string): {startIndex: number, endIndex:
 
     let start = startOfPreviousLine;
     let firstLine = text.substring(startOfPreviousLine, startOfCurrentLine - 1);
-    // if the separator row matches a yaml block indicator and the first line is missing
-    // a pipe, then we must assume that we are dealing with a header or yaml instead of a table
-    if (separatorRowMatch === '---' && !firstLine.includes('|')) {
+    // a table must have a pipe in either the header or the separator row
+    if (!separatorRowMatch.includes('|') && !firstLine.includes('|')) {
       continue;
     }
 


Test patch:
diff --git a/__tests__/get-all-tables-in-text.test.ts b/__tests__/get-all-tables-in-text.test.ts
index 35d7a48..57dac6b 100644
--- a/__tests__/get-all-tables-in-text.test.ts
+++ b/__tests__/get-all-tables-in-text.test.ts
@@ -206,6 +206,18 @@ const getTablesInTextTestCases: tablesInTextTestCase[] = [
     expectedTablesInText: 0,
     expectedPositions: [],
   },
+  {
+    name: 'does not match an empty list indicator with a blank line before it',
+    text: dedent`
+      ## Attendees
+      ${''}
+      -${' '}
+      ${''}
+      ## Agenda
+    `,
+    expectedTablesInText: 0,
+    expectedPositions: [],
+  },
 ];
 
 describe('Get All Tables in Text', () => {
diff --git a/__tests__/paragraph-blank-lines.test.ts b/__tests__/paragraph-blank-lines.test.ts
index 78a3db0..fdce785 100644
--- a/__tests__/paragraph-blank-lines.test.ts
+++ b/__tests__/paragraph-blank-lines.test.ts
@@ -284,7 +284,7 @@ ruleTest({
       testName: 'Table followed by header should only have 1 line after it',
       before: dedent`
         ### 常量
-
+        ${''}
         |  \`[[Link]]\`         |  A link to the file named "Link"  |
         |:--------------------|:----------------------------------|
         |  \`[[Link]]\`         |  A link to the file named "Link"  |
@@ -293,12 +293,12 @@ ruleTest({
         |  \`{ a: 1, b: 2 }\`   |  An object                        |
         |  \`date()\`           |                                   |
         |  \`dur()\`            |                                   |
-
+        ${''}
         ### 表达式
       `,
       after: dedent`
         ### 常量
-
+        ${''}
         |  \`[[Link]]\`         |  A link to the file named "Link"  |
         |:--------------------|:----------------------------------|
         |  \`[[Link]]\`         |  A link to the file named "Link"  |
@@ -307,9 +307,26 @@ ruleTest({
         |  \`{ a: 1, b: 2 }\`   |  An object                        |
         |  \`date()\`           |                                   |
         |  \`dur()\`            |                                   |
-
+        ${''}
         ### 表达式
       `,
     },
+    { // accounts for https://github.com/platers/obsidian-linter/issues/704
+      testName: 'Make sure that an empty list indicator does not have an extra empty line added around it',
+      before: dedent`
+        ## Attendees
+        ${''}
+        -${' '}
+        ${''}
+        ## Agenda
+      `,
+      after: dedent`
+        ## Attendees
+        ${''}
+        -${' '}
+        ${''}
+        ## Agenda
+      `,
+    },
   ],
 });