Last active
July 25, 2019 16:46
-
-
Save nortonwong/e2f9b07391088bcf05ab11b9369d629f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
const wrap = (prefix, suffix=prefix) => { | |
const pref = prefix instanceof Function ? prefix : () => prefix; | |
const suff = suffix instanceof Function ? suffix : () => suffix; | |
return e => e.innerHTML = `${pref(e)}${e.innerHTML}${suff(e)}`; | |
}; | |
const tab = `<span style="white-space: pre;"> </span>`; | |
$$(`b, strong`).map(wrap(`*`)); | |
$$(`h1, h2, h3, h4, h5, h6`).map(wrap(`**`)); | |
$$(`i, em`).map(wrap(`/`)); | |
$$(`a[href]`).map(wrap(``, e => ` <${e.href}>`)); | |
$$(`ol > li`).map(wrap(`#${tab}`, ``)); | |
$$(`ul > li`).map(wrap(`*${tab}`, ``)); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment