mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 11:33:34 +08:00
Do not write the title as h1 if it is in the yaml header
In general, we try to follow the conventions in the note parsed over whatever the default config. Related to #214
This commit is contained in:
@ -148,6 +148,7 @@ class NoteSerializer implements NoteSerializerInterface {
|
|||||||
note.title = emojiParser.emojify(title);
|
note.title = emojiParser.emojify(title);
|
||||||
|
|
||||||
propsUsed.add(settings.titleKey);
|
propsUsed.add(settings.titleKey);
|
||||||
|
settings.saveTitleAsH1 = false;
|
||||||
} else {
|
} else {
|
||||||
var startsWithH1 = false;
|
var startsWithH1 = false;
|
||||||
for (var line in LineSplitter.split(note.body)) {
|
for (var line in LineSplitter.split(note.body)) {
|
||||||
|
@ -217,5 +217,39 @@ Gee
|
|||||||
expect(txtNote.title.isEmpty, true);
|
expect(txtNote.title.isEmpty, true);
|
||||||
expect(txtNote.body, content);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user