Skip to content

Instantly share code, notes, and snippets.

@GitMurf
GitMurf / obsidian.templater.search.backlinks.js
Last active June 10, 2023 05:00
Open a [[Link]] under your cursor in Search pane with regex that shows all Backlinks.
<%*
//v0.2 - bug fix: when search results match just a file name and no line contents under it
//User can set the following two parameters
const resultFilePrefix = '## ';
const folderLocation = '/search';
const search = app.workspace.getLeavesOfType("search")[0];
const searchTerms = search.view.getQuery();
const arrCount = Array.from(search.view.dom.resultDomLookup);
@GitMurf
GitMurf / RemNote-css-block-quotes.css
Created March 1, 2023 02:00
RemNote CSS for block quotes
/* line up quotes with other bullets */
span.rem.relative.rn-editor__rem.rn-quote,
div.rem.relative.rn-editor__rem.rn-quote {
padding-left: 0px;
margin-left: -4px;
}
span.rem.relative.rn-editor__rem.rn-quote > div > div.rem-button__container,
div.rem.relative.rn-editor__rem.rn-quote > div.rem-button__container {
left: -48px !important;
@GitMurf
GitMurf / RemNote-css-reference-links-formattings.css
Created March 1, 2023 01:57
Custom CSS for tweaking the formatting of Rem references, URL links and pasted website links.
/* Default font-family and default 16 size */
:root {
--bullet-one: '●';
--bullet-one-pos-top: 5px;
--bullet-one-size: 9px;
--bullet-two: '■';
--bullet-two-pos-top: 5px;
--bullet-two-size: 9px;
--bullet-three: '○';
--bullet-three-pos-top: 3px;
<%*
const editor = app.workspace.activeLeaf.view.editor;
if(editor.somethingSelected() === true) {
let selectedText = editor.getSelection();
let splitLines = selectedText.split('\n');
let finalOutput = '';
let listItem = false;
let codeBlock = false;
splitLines.forEach(eachLine => {
@GitMurf
GitMurf / obsidian.templater.replace-block-ref-with-text.js
Last active January 27, 2023 21:42
Replace a block ref in the current line with the actual text from the block ref. It replicates Roam's feature where you right-click a block ref and choose "Replace as text".
<%*
//v1.1: Changed to using the new "view.editor" instead of deprecated "view.sourceMode.cmEditor"
let thisFile = this.app.workspace.getActiveFile();
let thisFileCache = this.app.metadataCache.getFileCache(thisFile);
let embedsOnPage = thisFileCache.embeds;
if(embedsOnPage) {
let cmEditorAct = this.app.workspace.activeLeaf.view.editor;
let curLine = cmEditorAct.getCursor().line;
@GitMurf
GitMurf / obsidian.templater.nlp-date-input.js
Created April 22, 2021 19:04
Requires @argenos Natural Language Dates Plugin. Pop up input box asks for date and then parses it as a date and turns it into a [[Daily Notes Page]] page ref.
<%*
//v1.0
let dueDateStr = await tp.system.prompt("Due Date");
let parseResult;
let parseResultLink;
if(dueDateStr) {
let nlDatesPlugin = this.app.plugins.getPlugin('nldates-obsidian');
parseResult = nlDatesPlugin.parseDate(dueDateStr);
if(parseResult){parseResultLink = '[' + '[' + parseResult.formattedString + ']]';}
@GitMurf
GitMurf / obsidian.templater.search.dnp.backlinks.js
Created September 23, 2021 19:45
obsidian.templater.search.dnp.backlinks.js
@GitMurf
GitMurf / obsidian.templater.query.section.keyword-page-name.js
Created May 30, 2022 05:53
When using headings with a [[page name]] in it, create a "search embed query" with all those headings expanded
<%*
const noteName = tp.file.title;
let queryKeyword = await tp.system.prompt("Keyword for Section search query (do NOT add [ ] brackets around it)", noteName);
if(queryKeyword) {
// Un-comment the next line if you want the keyword to require [] brackets around it for backlinks matching purposes
queryKeyword = `\\[\\[${queryKeyword}[\\|\\]]`; // the | pipe check accounts for alias links
tR = `
# Keyword Section Query
\`\`\`query