Skip to content

Instantly share code, notes, and snippets.

@geekman
Created May 12, 2018 11:07
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 geekman/2b7c75fc872269ed439add3c69702d38 to your computer and use it in GitHub Desktop.
Save geekman/2b7c75fc872269ed439add3c69702d38 to your computer and use it in GitHub Desktop.
JS to "fixup" ASCII art on old Apple docs, e.g https://support.apple.com/kb/TA40730
document.querySelector('.SUMMARY').childNodes.forEach(function(e) {
if (e.nodeType == Node.TEXT_NODE && (e.textContent.match(/[+|-]/g) || []).length > 2) {
var n = document.createElement('code');
n.textContent = e.textContent.replace(/^[\r\n]*(.*)[\r\n]*$/, '$1');
n.style = 'white-space:pre-wrap';
e.parentNode.replaceChild(n, e);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment