Skip to content

$ sequences in special variable values are mangled by preProcessTemplateBody #184

Open

Description

@VanshajPoonia

wrapInQuotes in preProcessTemplateBody writes the quoted line back with:

definitionsBlock = definitionsBlock.replace(firstMatch, wrappedString);

When the replacement is a string, String.prototype.replace treats $$, $&, $` and $' as special patterns. So a $ sequence in a special variable value is rewritten before the frontmatter is parsed.

---
template_title: Budget $$ report
---

creates a note titled Budget $ report, and

---
template_title: Price in $& dollars
---

creates a note titled Price in template_title: Price in $& dollars dollars, because $& inserts the whole matched line.

Passing a function instead, definitionsBlock.replace(firstMatch, () => wrappedString), inserts the string as is.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions