简体   繁体   中英

Blogger API - Render blog content on personal website

In its content attribute the blogger API returns an ugly blob of HTML. I would like to convert this HTML string data into a dom that I can parse. What is the best way to parse this text in order that I can re-render within a js widget I'm building for another website?

I'd rather not write my own parser that reverse engineers the HTML encoding that Google put into place. I'm ideally looking for a library which undoes the HTML escaping and then turns it into a dom which I can inspect with JQuery.

Apparently this question was based on some slightly false premises. I have since managed to successfully embed blogs in my website. I have been using AngularJS, which apparently escapes HTML by default before embedding it into the dom. This caused some heavy confusion from my side. The response from google is not escaped.

This means parsing it as a dom is simply a matter of calling jquery.parseHtml(). See: http://api.jquery.com/jquery.parsehtml/

Once this is done, whatever jquery transformations need to be made can be made using angularJS's JQLite by calling angular.element('').

Finally, the object can be bound to the document.

Alternatively, the raw content of the list of blog posts can be injected as an html string the regular angular way using something like this:

$scope.frontPagePosts = posts.map(function(post){
    post.content = $sce.trustAsHtml(post.content);
    return post;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM