Skip to content

Commit

Permalink
fix: quote titles in YAML frontmatter to escape special chars.
Browse files Browse the repository at this point in the history
  • Loading branch information
codito committed Dec 28, 2024
1 parent 0c900bf commit 35fc3f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Noted/Extensions/Writers/MarkdownWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public class MarkdownWriter(ILogger logger) : IDocumentWriter

public async Task Write(Configuration configuration, Document document, Stream output)
{
var writer = new StreamWriter(output, Encoding.UTF8)
{ AutoFlush = true };
var writer = new StreamWriter(output, Encoding.UTF8) { AutoFlush = true };
var title = !string.IsNullOrEmpty(document.Title) && document.Title.Contains(':') ? $"\"{document.Title}\"" : document.Title;

await writer.WriteLineAsync("---");
await writer.WriteLineAsync($"title: {document.Title}");
await writer.WriteLineAsync($"title: {title}");
await writer.WriteLineAsync($"author: {document.Author}");
await writer.WriteLineAsync($"start date: {document.CreatedDate}");
await writer.WriteLineAsync($"end date: {document.ModifiedDate}");
Expand Down

0 comments on commit 35fc3f9

Please sign in to comment.