Skip to content

Instantly share code, notes, and snippets.

@racng
Last active January 19, 2023 02:39
Show Gist options
  • Save racng/03774c48376ba623e31329db42931801 to your computer and use it in GitHub Desktop.
Save racng/03774c48376ba623e31329db42931801 to your computer and use it in GitHub Desktop.
Obsidian templater template that would format text selection into a callout quote block using Obsidian callout syntax.
<%*
//get selection
noteContent = tp.file.selection();
//get array of lines
lines = noteContent.split('\n')
//make a new string with > prepended to each line
let newContent = "";
lines.forEach(l => {
newContent += '> ' + l + "\n";
})
//remove the last newline character
newContent = newContent.replace(/\n$/, "");
//define callout header
header = "> [!quote]-\n"
// Return the complete callout block
return header + newContent;
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment