From be46e734bfb5baa6cd21b0c14ae49a805518853f Mon Sep 17 00:00:00 2001 From: tjex Date: Wed, 3 Apr 2024 18:16:58 +1100 Subject: [PATCH] fix: works, but with caveat of old tests breaking. It would seem that the old tesh test is not taking into account note titles with `"` marks. Therefore, the failing test may be a sign of the test needing to be updated, rather than this fix being void. --- internal/core/note_format.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/core/note_format.go b/internal/core/note_format.go index 563f9cd..ced3977 100644 --- a/internal/core/note_format.go +++ b/internal/core/note_format.go @@ -5,6 +5,7 @@ import ( "fmt" "regexp" "time" + "strings" ) // NoteFormatter formats notes to be printed on the screen. @@ -32,6 +33,11 @@ func newNoteFormatter(basePath string, template Template, linkFormatter LinkForm snippets = append(snippets, noteTermRegex.ReplaceAllString(snippet, termRepl)) } + //FIXME: if notes have `"` in their titles, they will break when + //executing `zk graph --format json` as `Link:...` gets unescaped quotes + //from `newLazyStringer`. Issue: https://github.com/zk-org/zk/issues/389 + // escaping the quotes breaks tesh tests, but is the test perhaps + // guarding a less robust solution? return template.Render(noteFormatRenderContext{ Filename: note.Filename(), FilenameStem: note.FilenameStem(), @@ -44,6 +50,7 @@ func newNoteFormatter(basePath string, template Template, linkFormatter LinkForm return "" } link, _ := linkFormatter(context) + link = strings.ReplaceAll(link, `"`, `\"`) // breaks tesh test return link }), Lead: note.Lead,