Question

I have a large chunk of HTML. In order for it to fit a certain container, I crop the HTML (not just the text) at, lets say, 200 characters. Obviously some of the tags will remain unclosed in this case. Is there any way, except writing the cleaner myself, to clean such cropped snippet without server being involved? Online services with public APIs that I can use from JS are acceptable.

Was it helpful?

Solution

You can try the cutter.js library, It's pretty new so I haven't heard much about it but it seems like what you're looking for as far as cropping goes, check out my fiddle testing it out: http://jsfiddle.net/JKirchartz/jwL8v/

OTHER TIPS

Google Closure library has an HTML Pretty Printer module. You should be able to fork off it: http://code.google.com/p/closure-library/source/browse/trunk/closure/goog/format/htmlprettyprinter.js

Also, if you are using jQuery, try http://www.davidpirek.com/blog/html-beautifier-jquery-plugin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top