diff --git a/scarlet_export/notable.py b/scarlet_export/notable.py index 67a73f5..9088014 100644 --- a/scarlet_export/notable.py +++ b/scarlet_export/notable.py @@ -31,8 +31,12 @@ def exportNotes(notesList, outputDir): '%Y-%m-%dT%H:%M:%SZ', modifiedTime ) - outputFileName = outputFolder + '/' \ - + created.replace(':', '') + '.md' + # use the heading as note file name if there is one + if note.title != '': + outputFileName = outputFolder + '/' + note.title + '.md' + else: + outputFileName = outputFolder + '/' \ + + created.replace(':', '') + '.md' # check if the folder exists outputPath = Path(outputFolder) if not outputPath.is_dir(): @@ -40,6 +44,8 @@ def exportNotes(notesList, outputDir): with open(outputFileName, encoding='utf-8', mode='w') as output: # print YAML front matter first output.write('---\n') + if note.title != '': + output.write('title: {0}\n'.format(note.title)) output.write('created: {0}\n'.format(created)) output.write('modified: {0}\n'.format(modified)) output.write('tags: [{0}]\n'.format(tags)) diff --git a/scarlet_export/note.py b/scarlet_export/note.py index 695ef07..7aa9474 100644 --- a/scarlet_export/note.py +++ b/scarlet_export/note.py @@ -23,5 +23,11 @@ def __init__(self, note, tags, folders): for tag in note['tags'].split(','): if tag != '': self.tags.append(tags[tag]) - noteContent = loads(note['description']) - self.content = noteContent['note'][0]['text'] + noteContent = loads(note['description'])['note'] + # note headings are optional in Scarlet + if len(noteContent) > 1: + self.title = noteContent[0]['text'] + self.content = noteContent[1]['text'] + else: + self.content = noteContent[0]['text'] + self.title = ''