Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created February 22, 2023 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttscoff/a8c902d533288a3b3b2e3ca47a75ee52 to your computer and use it in GitHub Desktop.
Save ttscoff/a8c902d533288a3b3b2e3ca47a75ee52 to your computer and use it in GitHub Desktop.
TextExpander JavaScript for generating Hugo youtube tag with a YouTube url in clipboard
var url = TextExpander.pasteboardText;
var youtubeRx = /(?:youtu\.be\/|youtube\.com\/watch\?v=)([a-z0-9_\-]+)$/i
if (youtubeRx.test(url)) {
var id = youtubeRx.exec(url)[1];
TextExpander.appendOutput(`{< youtube ${id}>}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment