Last active
August 29, 2015 14:06
-
-
Save erwan/3e125676868b16fa91b9 to your computer and use it in GitHub Desktop.
This file contains 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 htmlSerializer = function (element, content) { | |
// Don't wrap images in a <p> tag | |
if (element.type == "image") { | |
return '<img src="' + element.url + '" alt="' + element.alt + '">'; | |
} | |
// Add a class to hyperlinks | |
if (element.type == "hyperlink") { | |
return '<a class="some-link" href="' + element.url + '">' + content + '</a>'; | |
} | |
// Return null to stick with the default behavior | |
return null; | |
}; | |
var html = doc.getStructuredText('blog-post.body').asHtml(getLinkResolver(), htmlSerializer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment