From b165bff9aaa4f1736bbe4c151147e5a13b7fa3ed Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Thu, 15 Jul 2021 17:05:49 +0200 Subject: [PATCH] Capture frontmatter insertion fix and replace linebreak in insert after --- README.md | 3 ++- manifest.json | 2 +- package.json | 2 +- src/formatters/captureChoiceFormatter.ts | 5 +++-- versions.json | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ab8a704..fc7cc0c 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,10 @@ Quickly add new pages or content to your vault. You can also do a [manual installation](docs/ManualInstallation.md). ## What's new? -### 0.3.6 - 0.3.7 +### 0.3.6 - 0.3.8 - Added setting to create the 'Insert After' line if it isn't found. - (HOTFIX) Escape regular expression special characters in Insert After when searching for it +- (HOTFIX) Insert _after_ frontmatter ### 0.3.5 - You can now execute [inline JavaScript](docs/InlineScripts.md) in templates or captures. diff --git a/manifest.json b/manifest.json index 2256dcc..499ebc0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "quickadd", "name": "QuickAdd", - "version": "0.3.7", + "version": "0.3.8", "minAppVersion": "0.12.5", "description": "Quickly add new pages or content to your vault.", "author": "Christian B. B. Houmann", diff --git a/package.json b/package.json index da14f14..dec47fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quickadd", - "version": "0.3.7", + "version": "0.3.8", "description": "Quickly add new pages or content to your vault.", "main": "main.js", "scripts": { diff --git a/src/formatters/captureChoiceFormatter.ts b/src/formatters/captureChoiceFormatter.ts index da1fe36..cf35ce9 100644 --- a/src/formatters/captureChoiceFormatter.ts +++ b/src/formatters/captureChoiceFormatter.ts @@ -54,11 +54,12 @@ export class CaptureChoiceFormatter extends CompleteFormatter { const targetPosition = fileContentLines.findIndex(line => targetRegex.test(line)); if (targetPosition === -1) { if (this.choice.insertAfter?.createIfNotFound) { - const insertAfterLineAndFormatted: string = `${await this.format(this.choice.insertAfter.after)}\n${formatted}`; + const insertAfterLine: string = this.replaceLinebreakInString(await this.format(this.choice.insertAfter.after)); + const insertAfterLineAndFormatted: string = `${insertAfterLine}\n${formatted}`; if (this.choice.insertAfter?.createIfNotFoundLocation === CREATE_IF_NOT_FOUND_TOP) { const frontmatterEndPosition = this.file ? await this.getFrontmatterEndPosition(this.file) : 0; - return this.insertTextAfterPositionInBody(insertAfterLineAndFormatted, this.fileContent, frontmatterEndPosition - 1); + return this.insertTextAfterPositionInBody(insertAfterLineAndFormatted, this.fileContent, frontmatterEndPosition); } else { return this.insertTextAfterPositionInBody(insertAfterLineAndFormatted, this.fileContent, fileContentLines.length - 1); diff --git a/versions.json b/versions.json index 42126fc..098afb1 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,4 @@ { "0.2.16": "0.12.4", - "0.3.7": "0.12.5" + "0.3.8": "0.12.5" }