This one is a nice simple fix.
The reason is that the ESV API does not output a hyphen (-) character for expressing verse ranges, but instead an en dash (–).
However, the regex you are using to match verse references expects only a hyphen character, and so it fails to match with ESV’s own output.
For example if I input
1 Corinthians 13:1-3
we get the output
1 Corinthians 13:1–3
[1] If I speak in the tongues of men and of angels, but have not love, I am a noisy gong or a clanging cymbal. [2] And if I have prophetic powers, and understand all mysteries and all knowledge, and if I have all faith, so as to remove mountains, but have not love, I am nothing. [3] If I give away all I have, and if I deliver up my body to be burned, but have not love, I gain nothing. (ESV)
And you will see that indeed the ESV Copy does not show up when selecting the reference from the output, only the input.
A sensible solution is to modify the regex to accept hypens and dashes:
^(?:[1-3]\s+)?[A-Za-z]+\s+\d+:\d+(?:[-–—]\d+)?$
You’ll see I have included hypen -
, en dash –
and em dash —
to account for most possibilities you might encounter.
Some extra notes
-
I’ve edited your post to add code formatting using ``` marks – take a look at the source to see how.
-
You posted the same code for the Copy and Paste variants, I assume just a copy-paste oversight.
-
You probably don’t actually need two separate extensions for copy and paste. If you specify
paste-result
, you can Copy instead of Paste simply by holding shift (⇧) key. So you can get a two-for-one. -
The
network
entitlement is irrelevant for python code and so isn’t needed here. It only applies to JavaScript files. -
You can inspect the unicode codes of characters using PopClip’s Unicode Lens extension.
-
It’s possible to express your extension as a single snippet - that’s what I did for testing. My code is here.