Skip to content

Commit

Permalink
support folgezettel
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Sep 25, 2024
1 parent 21a2267 commit eefde67
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/formats/zettelkasten.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This page describes how to convert notes from Zettelkasten to Markdown.
This page describes how to convert notes from Zettelkasten (zkn3) to Markdown.

## General Information

Expand All @@ -18,6 +18,7 @@ Zettelkasten supports Markdown export. However, it doesn't convert everything an
- Each zettel is converted to a separate note.
- The note body of Zettelkasten is converted from [BBCode](https://en.wikipedia.org/wiki/BBCode) to Markdown.
- Resources and attachments are converted, if the original folders are next to the `.zkn3` file. I. e. `img` for images and `attachments` for attachments.
- Note sequences (Folgezettel) are linked at the end of the note.

## Known Limitations

Expand Down
19 changes: 17 additions & 2 deletions src/formats/zettelkasten.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Convert Zettelkasten notes to the intermediate format."""
"""Convert Zettelkasten (zkn3) notes to the intermediate format."""

import datetime as dt
from pathlib import Path
Expand Down Expand Up @@ -202,7 +202,22 @@ def convert(self, file_or_folder: Path):
note_imf.resources.append(
imf.Resource(attachments_folder / link.text)
)
case "luhmann" | "misc" | "zettel":
case "luhmann": # folgezettel
if item.text is None:
continue
# TODO: Ensure that this is called always
# after the initial note content is parsed.
sequences = []
for note_id in item.text.split(","):
text = f"[{note_id}]({note_id})"
sequences.append(text)
note_imf.note_links.append(
imf.NoteLink(text, note_id, note_id)
)
note_imf.body += (
"\n\n## Note Sequences\n\n" + ", ".join(sequences) + "\n"
)
case "misc" | "zettel":
pass # always None
case "manlinks":
pass # TODO: Should correspond to the parsed note links.
Expand Down

0 comments on commit eefde67

Please sign in to comment.