Created
March 6, 2012 04:37
-
-
Save jakebresnehan/1983542 to your computer and use it in GitHub Desktop.
This little bit of jQuery strips out all the unwanted code from the Campaign Monitor email and enables me to quickly add the email as a blog post.
This file contains hidden or 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
var output = ''; | |
$('.contentblock').each(function(){ | |
var heading = $(this).find('h2').text(); | |
var article_heading_h3 = $(this).find('h3 a').text(); | |
var article_heading_h3_link = $(this).find('h3 a').attr('href'); | |
var article_heading_h4 = $(this).find('h4 p a').text(); | |
var article_heading_h4_link = $(this).find('h4 p a').attr('href'); | |
var article_desc = $(this).find('h3').next('p').text(); | |
if(heading){ | |
heading = '<h2>' + heading + '</h2>' ; | |
output += heading; | |
} | |
if(article_heading_h3){ | |
article_heading_h3 = '<h3><a href="'+article_heading_h3_link+'">' + article_heading_h3 + '</a></h3>'; | |
output += article_heading_h3 | |
} | |
if(article_heading_h4){ | |
article_heading_h4 = '<h4><a href="'+article_heading_h4_link+'">' + article_heading_h4 + '</a></h4>'; | |
output += article_heading_h4 | |
} | |
if(article_desc){ | |
article_desc = '<p>' + article_desc + '</p>'; | |
output += article_desc; | |
} | |
}); | |
console.log(output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment