Would like to replace a variable and embed it in a code line / Surround

I would like to replace a variable and embed it in a code line:

So for example if I mark the following variable (input):

XXXXXXXX

it should be replaced by the following line (result):

<p>Share PMID via Email:<a href="mailto:?body=https%3A%2F%2Fpubmed.ncbi.nlm.nih.gov%2FXXXXXX%2F">Forward</a>

Would anyone have any ideas ?

many thanks
Jack

Popclip:

#popclip
name: PMID-Link
icon: PMID
javascript: popclip.pasteText('<p>Share PMID via Email:<a href="mailto:?body=https%3A%2F%2Fpubmed.ncbi.nlm.nih.gov%2F' + popclip.input.text + '%2F">Forward</a>')

(Select all the text and install the extension.)

I would – however – use a text expansion tool here (aText, Typinator, TextExpander, …) to expand this line after pressing e.g. pmid# and automatically putting in the content of your clipboard (the PubMed-ID) at the chosen location.

Kolkrabe

1 Like

works perfect !

thank you so much :slight_smile:

2 Likes

Dear Kolkrabe,

I was wondering how I could get out of one variable two lines at the same time ?

variable (input):

XXXXXXXX

it should be replaced by the following line (result):

<p>Share PMID via Email:<a href="mailto:?body=https%3A%2F%2Fpubmed.ncbi.nlm.nih.gov%2FXXXXXX%2F">Forward</a>

<p>Share PMID via WhatsApp:<a href="https://api.whatsapp.com/send?text=https%3A%2F%2Fpubmed.ncbi.nlm.nih.gov%2FXXXXXX%2F">Forward</a>35138026%2F">Share via WhatsApp</a>

Thank you so much again !

Best 

Jack

Here’s one way:

#popclip
name: PMID-Link
icon: PMID
javascript: | 
  const line1 = '<p>Share PMID via Email:<a href="mailto:?body=https%3A%2F%2Fpubmed.ncbi.nlm.nih.gov%2F' + popclip.input.text + '%2F">Forward</a>'
  const line2 = '<p>Share PMID via WhatsApp:<a href="https://api.whatsapp.com/send?text=https%3A%2F%2Fpubmed.ncbi.nlm.nih.gov%2F' + popclip.input.text +  ' %2F">Forward</a>35138026%2F">Share via WhatsApp</a>'
  popclip.pasteText(line1 + '\n' + line2)
1 Like