Skip to content

Instantly share code, notes, and snippets.

@raphaelrk
Last active May 11, 2020 23:34
Show Gist options
  • Save raphaelrk/99dadcbc6de542bce9480c7d4e6d25ea to your computer and use it in GitHub Desktop.
Save raphaelrk/99dadcbc6de542bce9480c7d4e6d25ea to your computer and use it in GitHub Desktop.
/**
* How to do markdown export, i.e. [Title](URL), in tabsave
* 1. Download the project from https://github.com/raphaelrk/tabsave
* 2. Change the following code in script.js (https://github.com/raphaelrk/tabsave/blob/master/script.js)
**/
// old code
return tabs.map(tab => (`
${tab.title}
<br>
<a href="${escapeHtml(tab.url)}">${escapeHtml(tab.url)}</a>
`)).join("<br>");
// new code
function escapeMarkdown(str) {
return str
.replace(/\[/g, "\\[")
.replace(/\]/g, "\\]")
.replace(/\(/g, "\\(")
.replace(/\)/g, "\\)")
}
return tabs.map(tab => `[${escapeMarkdown(tab.title)}](${escapeMarkdown(escapeHtml(tab.url)}))]`);
/**
* 3. Load the extension by going to chrome://extensions,
* turning on developer, pressing "load unpacked", then selecting the folder
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment