Skip to content

Instantly share code, notes, and snippets.

@aholmes
Last active August 29, 2015 14:04
Show Gist options
  • Save aholmes/8136779a7b01cf4e80b1 to your computer and use it in GitHub Desktop.
Save aholmes/8136779a7b01cf4e80b1 to your computer and use it in GitHub Desktop.
var container = $('.markdown-body'),
classes = {};
container.find('h2').each(function(i)
{
var className = $(this).text().replace(/[^-a-zA-Z0-9_ ]+/g, '').trim(),
currentClass, next;
classes[className] = {};
next = this;
do
{
next = next.nextElementSibling;
}
while(next.nodeName !== 'UL');
currentClass = next;
$(currentClass).find('li code').each(function(ci)
{
var fieldName = $(this).text().replace(/[^-a-zA-Z0-9_ ]+/g, '').trim(),
description = this.nextSibling;
classes[className][fieldName] = $(description).text();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment