From ad2918b8ddbde09d3305994f7973281a8a69614f Mon Sep 17 00:00:00 2001 From: dpilafian Date: Wed, 23 Feb 2022 01:22:05 -0800 Subject: [PATCH] Release v1.2.3 --- dist/pretty-print-json.css | 6 ++- dist/pretty-print-json.d.ts | 2 +- dist/pretty-print-json.dark-mode.css | 6 ++- dist/pretty-print-json.dev.js | 15 ++++--- dist/pretty-print-json.js | 15 ++++--- dist/pretty-print-json.min.js | 4 +- dist/pretty-print-json.umd.cjs | 15 ++++--- docs/dynamic/index.html | 6 +-- docs/index.html | 59 +++++++++++++++------------- package.json | 4 +- spec/dynamic.html | 6 +-- 11 files changed, 71 insertions(+), 67 deletions(-) diff --git a/dist/pretty-print-json.css b/dist/pretty-print-json.css index a85a791..0418b10 100644 --- a/dist/pretty-print-json.css +++ b/dist/pretty-print-json.css @@ -1,7 +1,9 @@ -/*! pretty-print-json v1.2.2 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v1.2.3 ~~ https://pretty-print-json.js.org ~~ MIT License */ /* Layout */ .json-container { font-family: menlo, consolas, monospace; font-style: normal; font-weight: bold; line-height: 1.4em; font-size: 0.9rem; transition: background-color 400ms; } +a.json-link { text-decoration: none; border-bottom: 1px solid; outline: none; } +a.json-link:hover { background-color: transparent; outline: none; } ol.json-lines { white-space: normal; padding-inline-start: 3em; margin: 0px; } ol.json-lines >li { white-space: pre; text-indent: 0.7em; line-height: 1.5em; padding: 0px; } ol.json-lines >li::marker { font-family: system-ui, sans-serif; font-weight: normal; } @@ -35,7 +37,7 @@ ol.json-lines >li:hover { background-color: lemonchiffon; } .dark-mode a.json-link { color: mediumorchid; } .dark-mode a.json-link:visited { color: slategray; } .dark-mode a.json-link:hover { color: violet; } -.dark-mode a.json-link:active { color: silver; } +.dark-mode a.json-link:active { color: slategray; } .dark-mode ol.json-lines >li::marker { color: silver; } .dark-mode ol.json-lines >li:nth-child(odd) { background-color: #222222; } .dark-mode ol.json-lines >li:nth-child(even) { background-color: #161616; } diff --git a/dist/pretty-print-json.d.ts b/dist/pretty-print-json.d.ts index 05e9527..605e1f7 100644 --- a/dist/pretty-print-json.d.ts +++ b/dist/pretty-print-json.d.ts @@ -1,4 +1,4 @@ -//! pretty-print-json v1.2.2 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v1.2.3 ~~ https://pretty-print-json.js.org ~~ MIT License export declare type FormatOptions = { indent?: number; diff --git a/dist/pretty-print-json.dark-mode.css b/dist/pretty-print-json.dark-mode.css index 9a850ca..dc63276 100644 --- a/dist/pretty-print-json.dark-mode.css +++ b/dist/pretty-print-json.dark-mode.css @@ -1,7 +1,9 @@ -/*! pretty-print-json v1.2.2 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v1.2.3 ~~ https://pretty-print-json.js.org ~~ MIT License */ /* Layout */ .json-container { font-family: menlo, consolas, monospace; font-style: normal; font-weight: bold; line-height: 1.4em; font-size: 0.9rem; transition: background-color 400ms; } +a.json-link { text-decoration: none; border-bottom: 1px solid; outline: none; } +a.json-link:hover { background-color: transparent; outline: none; } ol.json-lines { white-space: normal; padding-inline-start: 3em; margin: 0px; } ol.json-lines >li { white-space: pre; text-indent: 0.7em; line-height: 1.5em; padding: 0px; } ol.json-lines >li::marker { font-family: system-ui, sans-serif; font-weight: normal; } @@ -18,7 +20,7 @@ ol.json-lines >li::marker { font-family: system-ui, sans-serif; font-weight: nor a.json-link { color: mediumorchid; } a.json-link:visited { color: slategray; } a.json-link:hover { color: violet; } -a.json-link:active { color: silver; } +a.json-link:active { color: slategray; } ol.json-lines >li::marker { color: silver; } ol.json-lines >li:nth-child(odd) { background-color: #222222; } ol.json-lines >li:nth-child(even) { background-color: #161616; } diff --git a/dist/pretty-print-json.dev.js b/dist/pretty-print-json.dev.js index af80bad..d163145 100644 --- a/dist/pretty-print-json.dev.js +++ b/dist/pretty-print-json.dev.js @@ -1,7 +1,7 @@ -//! pretty-print-json v1.2.2 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v1.2.3 ~~ https://pretty-print-json.js.org ~~ MIT License const prettyPrintJson = { - version: '1.2.2', + version: '1.2.3', toHtml(thing, options) { const defaults = { indent: 3, lineNumbers: false, linkUrls: true, quoteKeys: false }; const settings = { ...defaults, ...options }; @@ -21,8 +21,6 @@ const prettyPrintJson = { const display = strType && settings.linkUrls ? value.replace(urlRegex, makeLink) : value; return spanTag(type, display); }; - const lineTag = (s) => `
  • ${s}
  • `; - const orderedListTag = (s) => ['
      ', s, '
    '].join('\n'); const replacer = (match, p1, p2, p3, p4) => { const part = { indent: p1, key: p2, value: p3, end: p4 }; const findName = settings.quoteKeys ? /(.*)(): / : /"([\w$]+)": |(.*): /; @@ -31,13 +29,14 @@ const prettyPrintJson = { const keyHtml = part.key ? spanTag('key', keyName) + spanTag('mark', ': ') : ''; const valueHtml = part.value ? buildValueHtml(part.value) : ''; const endHtml = spanTag('mark', part.end); - const result = indentHtml + keyHtml + valueHtml + endHtml; - return settings.lineNumbers ? lineTag(result) : result; + return indentHtml + keyHtml + valueHtml + endHtml; }; const jsonLine = /^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/mg; const json = JSON.stringify(thing, null, settings.indent) || 'undefined'; - const result = htmlEntities(json).replace(jsonLine, replacer); - return settings.lineNumbers ? orderedListTag(result) : result; + const html = htmlEntities(json).replace(jsonLine, replacer); + const makeLine = (line) => `
  • ${line}
  • `; + const addLineNumbers = (html) => ['
      ', ...html.split('\n').map(makeLine), '
    '].join('\n'); + return settings.lineNumbers ? addLineNumbers(html) : html; }, }; if (typeof window === "object") window.prettyPrintJson = prettyPrintJson; diff --git a/dist/pretty-print-json.js b/dist/pretty-print-json.js index 9ce8c2d..4bd6749 100644 --- a/dist/pretty-print-json.js +++ b/dist/pretty-print-json.js @@ -1,7 +1,7 @@ -//! pretty-print-json v1.2.2 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v1.2.3 ~~ https://pretty-print-json.js.org ~~ MIT License const prettyPrintJson = { - version: '1.2.2', + version: '1.2.3', toHtml(thing, options) { const defaults = { indent: 3, lineNumbers: false, linkUrls: true, quoteKeys: false }; const settings = { ...defaults, ...options }; @@ -21,8 +21,6 @@ const prettyPrintJson = { const display = strType && settings.linkUrls ? value.replace(urlRegex, makeLink) : value; return spanTag(type, display); }; - const lineTag = (s) => `
  • ${s}
  • `; - const orderedListTag = (s) => ['
      ', s, '
    '].join('\n'); const replacer = (match, p1, p2, p3, p4) => { const part = { indent: p1, key: p2, value: p3, end: p4 }; const findName = settings.quoteKeys ? /(.*)(): / : /"([\w$]+)": |(.*): /; @@ -31,13 +29,14 @@ const prettyPrintJson = { const keyHtml = part.key ? spanTag('key', keyName) + spanTag('mark', ': ') : ''; const valueHtml = part.value ? buildValueHtml(part.value) : ''; const endHtml = spanTag('mark', part.end); - const result = indentHtml + keyHtml + valueHtml + endHtml; - return settings.lineNumbers ? lineTag(result) : result; + return indentHtml + keyHtml + valueHtml + endHtml; }; const jsonLine = /^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/mg; const json = JSON.stringify(thing, null, settings.indent) || 'undefined'; - const result = htmlEntities(json).replace(jsonLine, replacer); - return settings.lineNumbers ? orderedListTag(result) : result; + const html = htmlEntities(json).replace(jsonLine, replacer); + const makeLine = (line) => `
  • ${line}
  • `; + const addLineNumbers = (html) => ['
      ', ...html.split('\n').map(makeLine), '
    '].join('\n'); + return settings.lineNumbers ? addLineNumbers(html) : html; }, }; export { prettyPrintJson }; diff --git a/dist/pretty-print-json.min.js b/dist/pretty-print-json.min.js index 970e471..adf624d 100644 --- a/dist/pretty-print-json.min.js +++ b/dist/pretty-print-json.min.js @@ -1,2 +1,2 @@ -//! pretty-print-json v1.2.2 ~~ https://pretty-print-json.js.org ~~ MIT License -function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c"+b+"":""},e=function(a){var b=/^"/.test(a)&&"string",e=["true","false"].includes(a)&&"boolean",f=b&&c.linkUrls?a.replace(/https?:\/\/[^\s"]+/g,function makeLink(a){return""+a+""}):a;return d(e||"null"===a&&"null"||b||"number",f)},f=function(a){return"
  • ".concat(a,"
  • ")},g=JSON.stringify(a,null,c.indent)||"undefined",h=function htmlEntities(a){return a.replace(/&/g,"&").replace(/\\"/g,"\"").replace(//g,">")}(g).replace(/^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/mg,function replacer(a,b,g,h,i){var j={indent:b,key:g,value:h,end:i},k=c.quoteKeys?/(.*)(): /:/"([\w$]+)": |(.*): /,l=j.indent||"",m=j.key&&j.key.replace(k,"$1$2"),n=j.key?d("key",m)+d("mark",": "):"",o=j.value?e(j.value):"",p=d("mark",j.end),q=l+n+o+p;return c.lineNumbers?f(q):q});return c.lineNumbers?function orderedListTag(a){return["
      ",a,"
    "].join("\n")}(h):h}};"object"===("undefined"==typeof window?"undefined":_typeof(window))&&(window.prettyPrintJson=prettyPrintJson); +//! pretty-print-json v1.2.3 ~~ https://pretty-print-json.js.org ~~ MIT License +function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c"+b+"":""},e=function(a){var b=/^"/.test(a)&&"string",e=["true","false"].includes(a)&&"boolean",f=b&&c.linkUrls?a.replace(/https?:\/\/[^\s"]+/g,function makeLink(a){return""+a+""}):a;return d(e||"null"===a&&"null"||b||"number",f)},f=JSON.stringify(a,null,c.indent)||"undefined",g=function htmlEntities(a){return a.replace(/&/g,"&").replace(/\\"/g,"\"").replace(//g,">")}(f).replace(/^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/mg,function replacer(a,b,f,g,h){var i={indent:b,key:f,value:g,end:h},j=c.quoteKeys?/(.*)(): /:/"([\w$]+)": |(.*): /,k=i.indent||"",l=i.key&&i.key.replace(j,"$1$2"),m=i.key?d("key",l)+d("mark",": "):"",n=i.value?e(i.value):"",o=d("mark",i.end);return k+m+n+o}),h=function(a){return"
  • ".concat(a,"
  • ")};return c.lineNumbers?function addLineNumbers(a){return["
      "].concat(_toConsumableArray(a.split("\n").map(h)),["
    "]).join("\n")}(g):g}};"object"===("undefined"==typeof window?"undefined":_typeof(window))&&(window.prettyPrintJson=prettyPrintJson); diff --git a/dist/pretty-print-json.umd.cjs b/dist/pretty-print-json.umd.cjs index 63015ba..a00804a 100644 --- a/dist/pretty-print-json.umd.cjs +++ b/dist/pretty-print-json.umd.cjs @@ -1,4 +1,4 @@ -//! pretty-print-json v1.2.2 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v1.2.3 ~~ https://pretty-print-json.js.org ~~ MIT License (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { @@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.prettyPrintJson = void 0; const prettyPrintJson = { - version: '1.2.2', + version: '1.2.3', toHtml(thing, options) { const defaults = { indent: 3, lineNumbers: false, linkUrls: true, quoteKeys: false }; const settings = { ...defaults, ...options }; @@ -33,8 +33,6 @@ const display = strType && settings.linkUrls ? value.replace(urlRegex, makeLink) : value; return spanTag(type, display); }; - const lineTag = (s) => `
  • ${s}
  • `; - const orderedListTag = (s) => ['
      ', s, '
    '].join('\n'); const replacer = (match, p1, p2, p3, p4) => { const part = { indent: p1, key: p2, value: p3, end: p4 }; const findName = settings.quoteKeys ? /(.*)(): / : /"([\w$]+)": |(.*): /; @@ -43,13 +41,14 @@ const keyHtml = part.key ? spanTag('key', keyName) + spanTag('mark', ': ') : ''; const valueHtml = part.value ? buildValueHtml(part.value) : ''; const endHtml = spanTag('mark', part.end); - const result = indentHtml + keyHtml + valueHtml + endHtml; - return settings.lineNumbers ? lineTag(result) : result; + return indentHtml + keyHtml + valueHtml + endHtml; }; const jsonLine = /^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/mg; const json = JSON.stringify(thing, null, settings.indent) || 'undefined'; - const result = htmlEntities(json).replace(jsonLine, replacer); - return settings.lineNumbers ? orderedListTag(result) : result; + const html = htmlEntities(json).replace(jsonLine, replacer); + const makeLine = (line) => `
  • ${line}
  • `; + const addLineNumbers = (html) => ['
      ', ...html.split('\n').map(makeLine), '
    '].join('\n'); + return settings.lineNumbers ? addLineNumbers(html) : html; }, }; exports.prettyPrintJson = prettyPrintJson; diff --git a/docs/dynamic/index.html b/docs/dynamic/index.html index f1f4865..b39dd60 100644 --- a/docs/dynamic/index.html +++ b/docs/dynamic/index.html @@ -14,7 +14,7 @@ - + @@ -119,21 +120,23 @@

    Interactive online tool to format JSON

    -
    +

    JSON input:

    -
    -
    - + +

    Colorized output:

    - + +
    + +
    -
    +
    @@ -178,7 +181,7 @@

    Colorized output:

    - + - +