Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Make the tool parse headings as well
Browse files Browse the repository at this point in the history
Signed-off-by: Timur Demin <me@tdem.in>
  • Loading branch information
tdemin committed Apr 9, 2019
1 parent e8b5d4e commit be543e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions scarlet_export/notable.py
Expand Up @@ -31,15 +31,21 @@ 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():
outputPath.mkdir()
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))
Expand Down
10 changes: 8 additions & 2 deletions scarlet_export/note.py
Expand Up @@ -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 = ''

0 comments on commit be543e6

Please sign in to comment.