views:

32

answers:

2

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).

A: 
$ (URL=www.google.com; echo "scale=2;"`lynx -nolist -dump $URL | wc -c`/`curl -silent $URL | wc -c` | bc)
.06

Wicked :) Though the nice HTML rendering of inputs in links skews the stats a bit.

zoul
Some less painful (1 click) would be better. Did I say I am using Windows? :)
Vili
A: 

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 >.

Vili