diff --git a/src/parser.ts b/src/parser.ts index 36bd554..432ba19 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -224,7 +224,8 @@ export class Parser { const splitVal = firstMatch.split(":"); const wrappedString = `${splitVal[0]}: "${splitVal.slice(1).join(":").trim()}"`; - definitionsBlock = definitionsBlock.replace(firstMatch, wrappedString); + // A replacer function stops "$" sequences in the value being read as replacement patterns + definitionsBlock = definitionsBlock.replace(firstMatch, () => wrappedString); } return definitionsBlock; diff --git a/tests/parser.spec.ts b/tests/parser.spec.ts index b7584bf..62ef174 100644 --- a/tests/parser.spec.ts +++ b/tests/parser.spec.ts @@ -436,6 +436,24 @@ describe("Template parser", () => { expect(parsedTemplate).toBeNull(); }); + test("should keep dollar signs in special variable values as written", async () => { + const template = { + id: "note-id", + title: "Some Template", + body: dedent` + --- + template_title: Budget $$ and $& report + + --- + ` + }; + + const parsedTemplate = await parser.parseTemplate(template); + + assert(parsedTemplate); + expect(parsedTemplate.title).toEqual("Budget $$ and $& report"); + }); + test("should skip empty values in tags special variable", async () => { const template = { id: "note-id",