Tool for displaying text / code ratio in html

I am looking for a firefox / firebug plugin (or any OFFLINE tool is ok) to display the real text / markup ratio.

There are online tools like http://www.seochat.com/seo-tools/code-to-text-ratio/ and this plugin for Firefox: https://addons.mozilla.org/en-US/firefox / addon / 150366 / (this is also online).

+3
source share
3 answers

I made a small script in PHP, the main part:

$toparse = "htmltext";
$toparse = preg_replace('/(<script.*?>.*?<\/script>|<style.*?>.*?<\/style>|<.*?>|\r|\n|\t)/ms', '', $toparse);  
$toparse = preg_replace('/ +/ms', ' ', $toparse);  
$textlen = strlen($toparse);

After that, there are several calculations.
This regex may be shorter, but it works. The only requirement is paired <and >.

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

HTML input links .

0
source

Source: https://habr.com/ru/post/1763622/


All Articles