Skip to content

Instantly share code, notes, and snippets.

View maximumdata's full-sized avatar
👋
Looking for work!

Mike Dettmer maximumdata

👋
Looking for work!
View GitHub Profile
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@maximumdata
maximumdata / imgsToFigs.js
Created December 22, 2016 14:13
Reusable ES6 code to transform <img> DOM elements into <figures> with the image's alt text as a <figcaption>
let processImages = (selector) => {
let container = document.querySelector(selector)
let images = Array.from(container.getElementsByTagName('img'))
images.forEach((e, a, i) => {
if (!(e.getAttribute('data-processed'))) {
let fig = document.createElement('figure')
fig.innerHTML = `<img data-processed="true" src="${e.src}"><figcaption>${e.alt}</figcaption>`
e.parentNode.replaceChild(fig, e)
}
})