<%* // Select active line // Source: https://gist.github.com/GitMurf/c52dfef13162d88375975e4eefedf3a7 const editor = app.workspace.activeLeaf.view.editor; const curLineNum = editor.getCursor().line; editor.setSelection({ line: curLineNum, ch: 0 }, { line: curLineNum, ch: editor.getLine(curLineNum).length }); let copiedStr = editor.getSelection(); copiedStr = copiedStr.trim();
// Replace formatting copiedStr = copiedStr.replace(/[*-]\s/, "")
// Append to Weekly
var appendFile = ${tp.date.now("YYYY")}-W${tp.date.now("WW")}
;
const append = * [[${tp.file.title}|${moment(tp.file.title).format("ddd (MMM D)")}]]: ${copiedStr}
; //text to append tp.date.now
var template = tp.file.find_tfile("✂️ Weekly Template");
const folder = app.vault.getAbstractFileByPath("20 Journals/2022");
// Create if non-existent
if (!tp.file.exists(appendFile)) {
await tp.file.create_new(template, appendFile, false, folder)
new Notice('🆕Created new Weekly!');
}
// Append to file
const originalContent = await app.vault.read(tp.file.find_tfile(appendFile));
const contentNew = ${originalContent}\n${append}
await app.vault.modify(tp.file.find_tfile(appendFile), contentNew)
new Notice('📌Appended to Weekly!');
// Print string
tR = * ${copiedStr} ([[${appendFile}|📅]])
;
%>