changed regular expression for table detection

This commit is contained in:
Gamosoft 2025-12-02 12:00:39 +01:00
parent d7c50eaac0
commit 994ae8a71a
2 changed files with 4 additions and 4 deletions

View File

@ -2968,8 +2968,8 @@ function noteApp() {
// List items: lines starting with -, *, + or a number (e.g. 1., 10.), excluding tasks [-] // List items: lines starting with -, *, + or a number (e.g. 1., 10.), excluding tasks [-]
const listItems = (content.match(/^\s*(?:[-*+]|\d+\.)\s+(?!\[)/gm) || []).length; const listItems = (content.match(/^\s*(?:[-*+]|\d+\.)\s+(?!\[)/gm) || []).length;
// Tables: separator rows containing both '|' and '---' // Tables: markdown table separator rows (| --- | --- |)
const tables = (content.match(/^(?=.*\|)(?=.*---).*$/gm) || []).length; const tables = (content.match(/^\s*\|(?:\s*:?-+:?\s*\|){1,}\s*$/gm) || []).length;
// Link count // Link count
const linkMatches = content.match(/\[([^\]]+)\]\(([^\)]+)\)/g) || []; const linkMatches = content.match(/\[([^\]]+)\]\(([^\)]+)\)/g) || [];

View File

@ -49,9 +49,9 @@ class Plugin:
re.findall(r'^\s*(?:[-*+]|\d+\.)\s+(?!\[)', content, re.MULTILINE) re.findall(r'^\s*(?:[-*+]|\d+\.)\s+(?!\[)', content, re.MULTILINE)
) )
# Tables: count separator rows containing both '|' and '---' # Tables: count markdown table separator rows (| --- | --- |)
tables = len( tables = len(
re.findall(r'^(?=.*\|)(?=.*---).*$', content, re.MULTILINE) re.findall(r'^\s*\|(?:\s*:?-+:?\s*\|){1,}\s*$', content, re.MULTILINE)
) )
# Markdown link count # Markdown link count