Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit b472862

Browse files
committed
inline quotes
1 parent a2fe25c commit b472862

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/services/ParseService.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,29 +316,36 @@ class Parse {
316316
}
317317

318318
private handleYamlBreaker(value: string, localSettings: LocalSettings, isInline?: boolean): string {
319-
// Do nothing if is inline
320-
if (isInline) {
321-
return value;
322-
}
323-
324319
// Remove a possible already existing quote wrapper
325320
if (value.startsWith('"') && value.endsWith('"')) {
326321
value = value.substring(1, value.length - 1);
327322
}
328323

324+
// Wrap in quotes if is configured to do so
325+
if (localSettings.frontmatter_quote_wrap) {
326+
return this.wrapWithQuotes(value);
327+
}
328+
329+
// Do nothing if is inline
330+
if (isInline) {
331+
return value;
332+
}
333+
329334
// Check possible markdown breakers of the yaml
330335
if (MarkdownBreakerRules.INIT_CHARS.some(c => value.startsWith(c)) ||
331336
MarkdownBreakerRules.BETWEEN_CHARS.some(rule => value.includes(rule)) ||
332-
MarkdownBreakerRules.UNIQUE_CHARS.some(c => value === c) ||
333-
localSettings.frontmatter_quote_wrap) {
334-
value = value.replaceAll(`\\`, ``);
335-
value = value.replaceAll(`"`, `\\"`);
336-
return `"${value}"`;
337+
MarkdownBreakerRules.UNIQUE_CHARS.some(c => value === c)) {
338+
return this.wrapWithQuotes(value);
337339
}
338-
339340
return value;
340341
}
341342

343+
private wrapWithQuotes(value: string): string {
344+
value = value.replaceAll(`\\`, ``);
345+
value = value.replaceAll(`"`, `\\"`);
346+
return `"${value}"`;
347+
}
348+
342349
/**
343350
* Singleton instance
344351
* @returns {VaultManager}

0 commit comments

Comments
 (0)