Skip to content

Instantly share code, notes, and snippets.

@uroybd
Last active August 5, 2023 15:55
Show Gist options
  • Save uroybd/ace3b8da785d806d15d549445a258841 to your computer and use it in GitHub Desktop.
Save uroybd/ace3b8da785d806d15d549445a258841 to your computer and use it in GitHub Desktop.
A minimal boox to obsidian converter for templater

<%* function getTitleAndAuthor(l) { l = l.replace("Reading Notes | <<", "").split(">>"); return { title: l[0], authors: l[1] } }

let file = app.workspace.getActiveFile() let content = await app.vault.read(file) let lines = content.split("\n"); let titleAndAuthor = getTitleAndAuthor(lines.shift());

notes = lines.join("\n").split("-------------------")

let output = # ${titleAndAuthor.title}${titleAndAuthor.authors ? "\n### " + titleAndAuthor.authors : ""}\n\n\n;

for (let i = 0; i < notes.length; i++) { if (notes[i]) { note = notes[i].split("Page No.: ").pop().split("【Note】")[0]; noteLines = note.split("\n") noteLines.shift(); if (noteLines[noteLines.length - 1].length == 0) { noteLines.pop(); } output += - ${noteLines.join("\n\t")}\n\n; } }

app.vault.modify(file, output); %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment