From 212b9ebe582299a9a39cd3cd28982c1d8b786a57 Mon Sep 17 00:00:00 2001 From: Peter Kaufman Date: Sat, 25 Jun 2022 15:39:45 -0400 Subject: [PATCH 1/3] had to ignore YAML for the addition of 2 spaces between continued content since for some reason remark considers the list form of an array to make the YAML sections no longer exempt from certain checks --- src/utils.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 98f97041..368cdcdb 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -16,6 +16,10 @@ export const codeBlockRegex = new RegExp(`${backtickBlockRegexTemplate}|${tildeB export const linkRegex = /((!?)\[[^[\n]*\]\([^[\n]*\))|(\[{2}[^[\n]*\]{2})/g; export const tagRegex = /#[^\s#]{1,}/g; +// Reused placeholders + +const yamlPlaceholder = '---\n---'; + // Helper functions /** @@ -100,6 +104,12 @@ export function makeEmphasisOrBoldConsistent(text: string, style: string, type: * @return {string} The text with two spaces at the end of lines of paragraphs, list items, and blockquotes where there were consecutive lines of content. */ export function addTwoSpacesAtEndOfLinesFollowedByAnotherLineOfTextContent(text: string): string { + // added the placeholder for YAML in order to prevent the accidental misconstruing of the YAML as a paragraph when an array is in multiline form (i.e. it has a list for the array elements) + const yamlMatches = text.match(yamlRegex); + if (yamlMatches) { + text = text.replace(yamlMatches[0], escapeDollarSigns(yamlPlaceholder)); + } + const positions: Position[] = getPositions('paragraph', text); if (positions.length === 0) { return text; @@ -126,6 +136,10 @@ export function addTwoSpacesAtEndOfLinesFollowedByAnotherLineOfTextContent(text: text = text.substring(0, position.start.offset) + paragraphLines.join('\n') + text.substring(position.end.offset); } + if (yamlMatches) { + text = text.replace(yamlPlaceholder, escapeDollarSigns(yamlMatches[0])); + } + return text; } @@ -180,7 +194,6 @@ export function ignoreCodeBlocksYAMLTagsAndLinks(text: string, func: (text: stri text = ret.text; const replacedCodeBlocks = ret.replacedCodeBlocks; - const yamlPlaceholder = '---\n---'; const yamlMatches = text.match(yamlRegex); if (yamlMatches) { text = text.replace(yamlMatches[0], escapeDollarSigns(yamlPlaceholder)); From aaebccfcff1b94ce223948f74afc7c3c3142b8cc Mon Sep 17 00:00:00 2001 From: Peter Kaufman Date: Sat, 25 Jun 2022 16:34:22 -0400 Subject: [PATCH 2/3] updating regex --- src/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 368cdcdb..ec81abb0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -13,7 +13,7 @@ export const backtickBlockRegexTemplate = fencedRegexTemplate.replaceAll('X', '` export const tildeBlockRegexTemplate = fencedRegexTemplate.replaceAll('X', '~'); export const indentedBlockRegex = '^((\t|( {4})).*\n)+'; export const codeBlockRegex = new RegExp(`${backtickBlockRegexTemplate}|${tildeBlockRegexTemplate}|${indentedBlockRegex}`, 'gm'); -export const linkRegex = /((!?)\[[^[\n]*\]\([^[\n]*\))|(\[{2}[^[\n]*\]{2})/g; +export const linkRegex = /((!?)\[[^[\n\]]*\]\([^[\n\]]*\))|(\[{2}[^[\n\]]*\]{2})/g; export const tagRegex = /#[^\s#]{1,}/g; // Reused placeholders @@ -112,6 +112,10 @@ export function addTwoSpacesAtEndOfLinesFollowedByAnotherLineOfTextContent(text: const positions: Position[] = getPositions('paragraph', text); if (positions.length === 0) { + if (yamlMatches) { + text = text.replace(yamlPlaceholder, escapeDollarSigns(yamlMatches[0])); + } + return text; } From eee5d5561dbca72c5d635b9605f831c6d04f0c4f Mon Sep 17 00:00:00 2001 From: Peter Kaufman Date: Sat, 25 Jun 2022 16:36:43 -0400 Subject: [PATCH 3/3] updated version info in preparation for release --- manifest.json | 2 +- versions.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 70121090..5591ca39 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-linter", "name": "Linter", - "version": "1.3.2", + "version": "1.3.3", "minAppVersion": "0.9.7", "description": "Enforces consistent markdown styling.", "author": "Victor Tao", diff --git a/versions.json b/versions.json index fbf8149f..0109124a 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.3.2": "0.9.7" + "1.3.3": "0.9.7" }