Tool for displaying text/code ratio in html [closed]
I am looking for a firefox/firebug plugin (or any OFFLINE tool is OK) to display the ratio of real text/markup.
There are online tools, like http://www.seochat.com/seo-tools/code-to-text-ratio/ and this Firefox plugin: https://addons.mozilla.org/en-US/firefox/addon/150366/ (this is online too).
I made a small script in PHP, the main part is:
$toparse = "htmltext";
$toparse = preg_replace('/(<script.*?>.*?<\/script>|<style.*?>.*?<\/style>|<.*?>|\r|\n|\t)/ms', '', $toparse);
$toparse = preg_replace('/ +/ms', ' ', $toparse);
$textlen = strlen($toparse);
There are some calculations after this.
That regex can be shorter, but it works. The only requirement is paired <
and >
.
$ (URL=www.google.com; echo "scale=2;"`lynx -nolist -dump $URL | wc -c`/`curl -silent $URL | wc -c` | bc)
.06
Though the nice HTML rendering of input
s in links
skews the stats a bit.
精彩评论