I’m running into an issue with two custom extensions I’ve made not showing in certain situations.
First Extension ESV Copy
I select a Bible verse like John 1:1 or John 1:1-4 and the extension will grab the verse’s Text using the ESV API and copy it to the clipboard. This works repeatedly usually.
Second Extension ESV Paste
I select a Bible verse like John 1:1 or John 1:1-4 and the extension will grab the verse’s Text using the ESV API and paste it.
If I run ESV Paste it will paste the Book, Verse, and Verse text. If I go back to the John 1:1 or John 1-1-4 All PopClip options show up except these two extensions.
I can select other text or other verses and no issues but if I come back to the output of ESV Paste and just select John 1:1 or John 1:1-4 Neither of the two options come up, I’ve replicated this in Obsidian Notes and Apple Notes, If I run ESV Paste on a verse and go back to just the John 1:1 neither option appears, but If I just do ESV Copy I can run that a dozen times and it works each time…
I’m just wondering why that would be and I’m sure it’s something I’m overlooking.
YAML for ESV Copy
name: ESV Copy
identifier: com.example.popclip.esvcopy
entitlements: [network]
after: copy-result
regex: '^(?:[1-3]\s+)?[A-Za-z]+\s+\d+:\d+(?:-\d+)?$'
shell script file: esv_lookup.py
interpreter: python3
YAML for ESV Paste
name: ESV Paste
identifier: com.example.popclip.esvpaste
entitlements: [network]
after: paste-result
regex: '^(?:[1-3]\s+)?[A-Za-z]+\s+\d+:\d+(?:-\d+)?$'
shell script file: esv_lookup.py
interpreter: python3
Python for anyone interested (insert your API Key)
#!/usr/bin/env python3
# esv_lookup.py – Fetch Bible passage text from the ESV API and output to stdout.
import os
import json
from urllib import request, parse
# **Configuration**: ESV API credentials and endpoint
API_KEY = "API-KEY-Goes-Here" # ESV API key (replace with your own if needed)
API_URL = "https://api.esv.org/v3/passage/text/" # ESV Passage Text API endpoint
# (For other translations, use their API URL and key here. E.g., update API_URL for a different service)
# Get the Bible reference from the PopClip selection
reference = os.environ.get("POPCLIP_TEXT", "").strip()
# Prepare query parameters for the API request to minimize clutter in the output
params = {
"q": reference,
"include-footnotes": "false", # omit footnote call markers for cleaner text
"include-footnote-body": "false", # do not include footnote text at the bottom
"include-headings": "false" # omit section headings to focus only on verses
# (By default, verse numbers and passage reference are included as True, which we want)
# You can add or adjust parameters here for formatting tweaks.
# For example, to exclude verse numbers, set "include-verse-numbers": "false"
}
query_string = parse.urlencode(params)
# Make the HTTP request to the ESV API
req = request.Request(f"{API_URL}?{query_string}")
req.add_header("Authorization", f"Token {API_KEY}") # supply API key in the header
with request.urlopen(req) as resp:
data = json.load(resp)
# Extract the passage text from the JSON response
passages = data.get("passages", [])
if passages:
text = passages[0].strip()
else:
text = "Error: Verse text not found."
# Output the passage text to stdout (PopClip will capture this and copy it)
print(text, end="")