Skip to content

Instantly share code, notes, and snippets.

@mcdado
Last active August 29, 2015 14:01
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 mcdado/34b9ce0d55d3a07dc339 to your computer and use it in GitHub Desktop.
Save mcdado/34b9ce0d55d3a07dc339 to your computer and use it in GitHub Desktop.
Extract WWDC videos' info to YAML with jQuery
var sessions = [],
re = /\"/g;
jQuery("li.session").each(function () {
var current = jQuery(this),
session = {
'id' : current.attr("id").toString().replace('-video', ''),
'title' : current.find(".title").text(),
'description' : current.find(".description p:nth-child(2)").text(),
'track' : current.find(".track").text()
};
sessions.push(session);
});
sessions.sort(function (a, b) {
return a.id - b.id;
});
jQuery(sessions).each(function () {
console.log(this.id + ':\n\t:description: "' + this.description.replace(re,"'") + '"\n\t:title: "' + this.title + '"\n\t:track: ' + this.track)
});
@mcdado
Copy link
Author

mcdado commented Jun 9, 2014

Now properly replaces all occurrences of double quotes in the text with single quotes, thus formatting properly the YAML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment