Skip to content

Instantly share code, notes, and snippets.

@Matsuyanagi
Created January 27, 2021 15:40
Show Gist options
  • Save Matsuyanagi/1a091e543cae2f1c2353f6ba50d5fd53 to your computer and use it in GitHub Desktop.
Save Matsuyanagi/1a091e543cae2f1c2353f6ba50d5fd53 to your computer and use it in GitHub Desktop.
Create Link markdown
name:
markdown
Format:
%title%\n%url%
filter:
const matches = s.match( /^(.+)\n([^\n]+)$/ );let title = matches[ 1 ];let url = matches[ 2 ];if ( url.match(/^https:\/\/www\.amazon\.co\.jp.*\/(dp|gp|ASIN|product)/) ){const dp_matches = url.match( /\/(dp|gp|ASIN|product)\/([0-9A-Z]{10})([^0-9A-Z])/ );const dp = "dp/" + dp_matches[ 2 ] + "/";url = "https://www.amazon.co.jp/" + dp;title = title.replace( / \| .*$/, "");title = title.replace( /[A-Za-z0-9]/g, c => String.fromCharCode(c.charCodeAt(0) - 0xFEE0) );title = title.replace( / /g, " ");}return "[" + title + "](" + url + ")";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment