Repository navigation
fix(#177): quote special variable values that contain double quotes - #182
Open
VanshajPoonia wants to merge 1 commit into
Open
VanshajPoonia wants to merge 1 commit into
VanshajPoonia wants to merge 1 commit into
Conversation
…otes
wrapInQuotes skipped any value containing a double quote, assuming the
user had quoted it. Values whose quotes sit inside a helper argument,
such as {{ datetime format="YYYY" }}, were then left unquoted and the
frontmatter failed to parse.
Only skip values that start with a quote, and escape backslashes and
double quotes when wrapping so the value comes out as written.
VanshajPoonia
marked this pull request as ready for review
October 12, 2026 17:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #177
Fixes #156
What
wrapInQuotesnow skips a value only when it starts with a quote, as suggested in the issue. When it wraps a value, it escapes backslashes and double quotes so YAML reads the value back exactly as written.Why
The old check skipped any value containing
", so a value like{{ datetime format="dddd D MMMM YYYY" }}was left unquoted and YAML failed on the leading{. That is the "There was an error parsing this template" reported in #156.Once those values are wrapped, escaping is needed: an unescaped
"would end the YAML string early, and backslashes inside double quotes are YAML escape sequences.Behaviour changes
"but don't start with a quote are now wrapped. Before, they were parsed as plain YAML scalars, which worked unless they started with{. The parsed value is the same."were wrapped unescaped, so YAML read backslashes as escapes:\tbecame a tab and\Qfailed to parse.Testing
template_title,template_tagsandtemplate_todo_alarm. It fails on master with the YAMLException from Error when parsing date #156 and passes with the change.deis read by moment as date tokens, which is down to the format string.)devbranch, with the plugin loaded through--dev-plugins: a template withtemplate_title: {{ datetime format="dddd D MMMM YYYY" }}andtemplate_tags: {{ datetime format="YYYY" }}, weeklynow creates the note with the expected title and tags. On master, it shows the YAMLException.src/parser.ts.AI Assistance Disclosure
I used an AI coding assistant to investigate the issue, write the fix and the tests, and draft this description. The tests and lint pass locally, and the fix was checked end to end in a Joplin desktop dev build.