diff --git a/lib/core/note_serializer.dart b/lib/core/note_serializer.dart index d7e8f779..7b5562dc 100644 --- a/lib/core/note_serializer.dart +++ b/lib/core/note_serializer.dart @@ -148,6 +148,7 @@ class NoteSerializer implements NoteSerializerInterface { note.title = emojiParser.emojify(title); propsUsed.add(settings.titleKey); + settings.saveTitleAsH1 = false; } else { var startsWithH1 = false; for (var line in LineSplitter.split(note.body)) { diff --git a/test/note_test.dart b/test/note_test.dart index 16e71c1d..f83684a7 100644 --- a/test/note_test.dart +++ b/test/note_test.dart @@ -217,5 +217,39 @@ Gee expect(txtNote.title.isEmpty, true); expect(txtNote.body, content); }); + + test('Yaml is not touched with yaml disabled', () async { + var content = """--- +layout: post +title: Blogging +date: 2020-08-12T13:53:52+02:00 +categories: can-learn-foo +permalink: /:categories +--- + +Blah blah"""; + + var notePath = p.join(tempDir.path, "note63345.md"); + await File(notePath).writeAsString(content); + + var parentFolder = NotesFolderFS(null, tempDir.path); + var note = Note(parentFolder, notePath); + await note.load(); + + note.body = "Howdy"; + await note.save(); + + var actualContent = await File(notePath).readAsString(); + var expectedContent = """--- +layout: post +title: Blogging +date: 2020-08-12T13:53:52+02:00 +categories: can-learn-foo +permalink: /:categories +--- + +Howdy"""; + expect(actualContent, expectedContent); + }); }); }