Add my handrolled Obsidian extension for PopClip

This commit is contained in:
Danielle McLean 2023-11-16 13:12:14 +11:00
parent cbe482664b
commit 577c2daa72
Signed by: 00dani
GPG key ID: 52C059C3B22A753E
3 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,13 @@
---
name: OBClipper
identifier: me.00dani.obclipper
icon: iconify:simple-icons:obsidian
popclip version: 4225
options:
- identifier: vault
label: Vault Name
type: string
default value: silica
shell script file: clip.zsh
capture html: true

View file

@ -0,0 +1,9 @@
#!/bin/zsh
uriencode() {
jq -nr --arg input $1 '$input | @uri'
}
HOOK="$(osascript -l JavaScript hooked.js)"
CLIPPING="$POPCLIP_MARKDOWN"
[[ -n $HOOK ]] && CLIPPING+=$'\n'"$HOOK #clipped"
exec open "obsidian://advanced-uri?vault=$(uriencode $POPCLIP_OPTION_VAULT)&daily=true&mode=append&data=$(uriencode $CLIPPING)"

View file

@ -0,0 +1,12 @@
(function() {
const titleSpecials = /([\[\]\\*_])/g;
const urlSpecials = /([()\\])/g;
const mdEscape = (str, specials) => str.replace(specials, '\\$1');
const app = Application('Hookmark');
let mark = app.bookmarkFromActiveWindow();
if (typeof mark === 'string') {
delay(1);
mark = app.bookmarkByRequestHandle(mark);
}
return `[${mdEscape(mark.name(), titleSpecials)}](${mdEscape(mark.address(), urlSpecials)})`;
})();