diff --git a/html/overview.html b/html/overview.html index af34f6c..f2a7136 100644 --- a/html/overview.html +++ b/html/overview.html @@ -1,8 +1,8 @@
Overview
-

vkBeautify is a small, simple and powerfull javascript plugin to beautify ( pretty print ) -or minify text in following formats:

    +

    vkBeautify is a small, simple and powerfull javascript plugin to beautify ( pretty print ) +or minify text in following formats:

    • XML
    • JSON
    • CSS
    • @@ -10,7 +10,8 @@
    .
    -This script is also implemented for nodeJS platform as "pretty-data" module. +This script is also implemented for nodeJS platform as +"pretty-data" module.

    Consider to use it if you:

      @@ -22,7 +23,7 @@

      This plugin:

        -
      1. less then 3k minified
      2. +
      3. less then 5k minified
      4. no configuration is needed
      5. simple to use: it is a single function with one parameter
      6. takes less then 5 mSec to process 50K text
        diff --git a/vkbeautify.js b/vkbeautify.js index 447808a..33cc2f0 100644 --- a/vkbeautify.js +++ b/vkbeautify.js @@ -107,25 +107,15 @@ vkbeautify.prototype.xml = function(text) { vkbeautify.prototype.json = function(text) { - var ar = text.replace(/\s{0,}\{\s{0,}/g,"{") - .replace(/\s{0,}\[$/g,"[") - .replace(/\[\s{0,}/g,"[") - .replace(/\s{0,}\}\s{0,}/g,"}") - .replace(/\s{0,}\]\s{0,}/g,"]") - .replace(/\"\s{0,}\,/g,'",') - .replace(/\,\s{0,}\"/g,',"') - .replace(/\"\s{0,}:/g,'":') - .replace(/:\s{0,}\"/g,':"') - .replace(/:\s{0,}\[/g,':[') - - .replace(/\{/g,"~::~{~::~") - .replace(/\[/g,"[~::~") - .replace(/\}/g,"~::~}") - .replace(/\]/g,"~::~]") - .replace(/\"\,/g,'",~::~') - .replace(/\,\"/g,',~::~"') - .replace(/~::~\s{0,}~::~/g,"~::~") - .split('~::~'), + var ar = this.jsonmin(text).replace(/\{/g,"~::~{~::~") + .replace(/\[/g,"[~::~") + .replace(/\}/g,"~::~}") + .replace(/\]/g,"~::~]") + .replace(/\"\,/g,'",~::~') + .replace(/\,\"/g,',~::~"') + .replace(/\]\,/g,'],~::~') + .replace(/~::~\s{0,}~::~/g,"~::~") + .split('~::~'), len = ar.length, deep = 0, @@ -244,7 +234,7 @@ function split_sql(str, tab) { .split('~::~'); } -vkbeautify.prototype.sql = function(text, brakeOnComma) { +vkbeautify.prototype.sql = function(text) { var ar_by_quote = text.replace(/\s{1,}/g," ") .replace(/\'/ig,"~::~\'") @@ -318,7 +308,11 @@ vkbeautify.prototype.jsonmin = function(text) { .replace(/\"\s{0,}\,/g,'",') .replace(/\,\s{0,}\"/g,',"') .replace(/\"\s{0,}:/g,'":') - .replace(/:\s{0,}\"/g,':"'); + .replace(/:\s{0,}\"/g,':"') + .replace(/:\s{0,}\[/g,':[') + .replace(/\,\s{0,}\[/g,',[') + .replace(/\,\s{2,}/g,', ') + .replace(/\]\s{0,},\s{0,}\[/g,'],['); } vkbeautify.prototype.cssmin = function(text, preserveComments) {