From c763ad3370ecadf7ff2497549fc296768b5e98be Mon Sep 17 00:00:00 2001 From: dpilafian Date: Tue, 2 Jan 2024 22:31:47 -0800 Subject: [PATCH] Release v2.1.1 --- LICENSE.txt | 2 +- README.md | 4 ++-- dist/css/pretty-print-json.css | 2 +- dist/css/pretty-print-json.dark-mode.css | 2 +- dist/css/pretty-print-json.dark-mode.min.css | 2 +- dist/css/pretty-print-json.min.css | 2 +- dist/css/pretty-print-json.prefers.css | 2 +- dist/css/pretty-print-json.prefers.min.css | 2 +- dist/pretty-print-json.d.ts | 2 +- dist/pretty-print-json.dev.js | 4 ++-- dist/pretty-print-json.js | 4 ++-- dist/pretty-print-json.min.js | 4 ++-- dist/pretty-print-json.umd.cjs | 4 ++-- docs/dynamic/index.html | 4 ++-- docs/index.html | 4 ++-- package.json | 10 +++++----- spec/dynamic.html | 4 ++-- spec/interactive.html | 4 ++-- 18 files changed, 31 insertions(+), 31 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 1b8e553..c4a1768 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2023 Individual contributors to pretty-print-json +Copyright (c) 2018-2024 Individual contributors to pretty-print-json Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 469536d..c5ad2da 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ https://pretty-print-json.js.org ### 1. Web browser Load from the [jsdelivr.com CDN](https://www.jsdelivr.com/package/npm/pretty-print-json): ```html - + ... - + ``` For **dark mode**, replace `pretty-print-json.css` with `pretty-print-json.dark-mode.css` in the `` tag. diff --git a/dist/css/pretty-print-json.css b/dist/css/pretty-print-json.css index 93ae640..c1a27f1 100644 --- a/dist/css/pretty-print-json.css +++ b/dist/css/pretty-print-json.css @@ -1,4 +1,4 @@ -/*! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v2.1.1 ~~ 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; } diff --git a/dist/css/pretty-print-json.dark-mode.css b/dist/css/pretty-print-json.dark-mode.css index 22021ff..1feacb8 100644 --- a/dist/css/pretty-print-json.dark-mode.css +++ b/dist/css/pretty-print-json.dark-mode.css @@ -1,4 +1,4 @@ -/*! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v2.1.1 ~~ 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; } diff --git a/dist/css/pretty-print-json.dark-mode.min.css b/dist/css/pretty-print-json.dark-mode.min.css index a6deb19..0e9aab7 100644 --- a/dist/css/pretty-print-json.dark-mode.min.css +++ b/dist/css/pretty-print-json.dark-mode.min.css @@ -1,2 +1,2 @@ -/*! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v2.1.1 ~~ https://pretty-print-json.js.org ~~ MIT License */ .json-container{font-family:menlo,consolas,monospace;font-style:normal;font-weight:700;line-height:1.4em;font-size:.9rem;transition:background-color 400ms}a.json-link{text-decoration:none;border-bottom:1px solid;outline:0}a.json-link:hover{background-color:transparent;outline:0}ol.json-lines{white-space:normal;padding-inline-start:3em;margin:0}ol.json-lines>li{white-space:pre;text-indent:.7em;line-height:1.5em;padding:0}ol.json-lines>li::marker{font-family:system-ui,sans-serif;font-weight:400;color:silver}.json-boolean,.json-key,.json-mark,.json-null,.json-number,.json-string,a.json-link,ol.json-lines>li{transition:all 400ms}.json-container{background-color:#000}.json-key{color:#cd5c5c}.json-string{color:khaki}.json-number{color:#00bfff}.json-boolean{color:#3cb371}.json-null{color:#ff8c00}.json-mark{color:silver}a.json-link{color:#ba55d3}a.json-link:visited{color:#708090}a.json-link:hover{color:violet}a.json-link:active{color:#708090}ol.json-lines>li:nth-child(odd){background-color:#222}ol.json-lines>li:nth-child(even){background-color:#161616}ol.json-lines>li:hover{background-color:#696969} diff --git a/dist/css/pretty-print-json.min.css b/dist/css/pretty-print-json.min.css index 069841d..b5d2950 100644 --- a/dist/css/pretty-print-json.min.css +++ b/dist/css/pretty-print-json.min.css @@ -1,2 +1,2 @@ -/*! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v2.1.1 ~~ https://pretty-print-json.js.org ~~ MIT License */ .json-container{font-family:menlo,consolas,monospace;font-style:normal;font-weight:700;line-height:1.4em;font-size:.9rem;transition:background-color 400ms}a.json-link{text-decoration:none;border-bottom:1px solid;outline:0}a.json-link:hover{background-color:transparent;outline:0}ol.json-lines{white-space:normal;padding-inline-start:3em;margin:0}ol.json-lines>li{white-space:pre;text-indent:.7em;line-height:1.5em;padding:0}ol.json-lines>li::marker{font-family:system-ui,sans-serif;font-weight:400;color:#696969}.json-boolean,.json-key,.json-mark,.json-null,.json-number,.json-string,a.json-link,ol.json-lines>li{transition:all 400ms}.json-container{background-color:#fff}.json-key{color:brown}.json-string{color:olive}.json-number{color:navy}.json-boolean{color:teal}.json-null{color:#696969}.json-mark{color:#000}a.json-link{color:purple}a.json-link:visited{color:#708090}a.json-link:hover{color:#8a2be2}.dark-mode a.json-link:visited,a.json-link:active{color:#708090}ol.json-lines>li:nth-child(odd){background-color:#dcdcdc}ol.json-lines>li:nth-child(even){background-color:#f5f5f5}ol.json-lines>li:hover{background-color:#fffacd}.dark-mode .json-container{background-color:#000}.dark-mode .json-key{color:#cd5c5c}.dark-mode .json-string{color:khaki}.dark-mode .json-number{color:#00bfff}.dark-mode .json-boolean{color:#3cb371}.dark-mode .json-null{color:#ff8c00}.dark-mode .json-mark{color:silver}.dark-mode a.json-link{color:#ba55d3}.dark-mode a.json-link:hover{color:violet}.dark-mode a.json-link:active{color:#708090}.dark-mode ol.json-lines>li::marker{color:silver}.dark-mode ol.json-lines>li:nth-child(odd){background-color:#222}.dark-mode ol.json-lines>li:nth-child(even){background-color:#161616}.dark-mode ol.json-lines>li:hover{background-color:#696969} diff --git a/dist/css/pretty-print-json.prefers.css b/dist/css/pretty-print-json.prefers.css index 3bdcd77..4bedaee 100644 --- a/dist/css/pretty-print-json.prefers.css +++ b/dist/css/pretty-print-json.prefers.css @@ -1,4 +1,4 @@ -/*! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v2.1.1 ~~ 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; } diff --git a/dist/css/pretty-print-json.prefers.min.css b/dist/css/pretty-print-json.prefers.min.css index 068c50a..55eafd5 100644 --- a/dist/css/pretty-print-json.prefers.min.css +++ b/dist/css/pretty-print-json.prefers.min.css @@ -1,2 +1,2 @@ -/*! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v2.1.1 ~~ https://pretty-print-json.js.org ~~ MIT License */ .json-container{font-family:menlo,consolas,monospace;font-style:normal;font-weight:700;line-height:1.4em;font-size:.9rem;transition:background-color 400ms}a.json-link{text-decoration:none;border-bottom:1px solid;outline:0}a.json-link:hover{background-color:transparent;outline:0}ol.json-lines{white-space:normal;padding-inline-start:3em;margin:0}ol.json-lines>li{white-space:pre;text-indent:.7em;line-height:1.5em;padding:0}ol.json-lines>li::marker{font-family:system-ui,sans-serif;font-weight:400;color:#696969}.json-boolean,.json-key,.json-mark,.json-null,.json-number,.json-string,a.json-link,ol.json-lines>li{transition:all 400ms}.json-container{background-color:#fff}.json-key{color:brown}.json-string{color:olive}.json-number{color:navy}.json-boolean{color:teal}.json-null{color:#696969}.json-mark{color:#000}a.json-link{color:purple}a.json-link:visited{color:#708090}a.json-link:hover{color:#8a2be2}a.json-link:active{color:#708090}ol.json-lines>li:nth-child(odd){background-color:#dcdcdc}ol.json-lines>li:nth-child(even){background-color:#f5f5f5}ol.json-lines>li:hover{background-color:#fffacd}@media (prefers-color-scheme:dark){.json-container{background-color:#000}.json-key{color:#cd5c5c}.json-string{color:khaki}.json-number{color:#00bfff}.json-boolean{color:#3cb371}.json-null{color:#ff8c00}.json-mark{color:silver}a.json-link{color:#ba55d3}a.json-link:visited{color:#708090}a.json-link:hover{color:violet}a.json-link:active{color:#708090}ol.json-lines>li::marker{color:silver}ol.json-lines>li:nth-child(odd){background-color:#222}ol.json-lines>li:nth-child(even){background-color:#161616}ol.json-lines>li:hover{background-color:#696969}} diff --git a/dist/pretty-print-json.d.ts b/dist/pretty-print-json.d.ts index 0389d4c..0b674e9 100644 --- a/dist/pretty-print-json.d.ts +++ b/dist/pretty-print-json.d.ts @@ -1,4 +1,4 @@ -//! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v2.1.1 ~~ https://pretty-print-json.js.org ~~ MIT License export type FormatSettings = { indent: number; diff --git a/dist/pretty-print-json.dev.js b/dist/pretty-print-json.dev.js index 148cf21..590bfca 100644 --- a/dist/pretty-print-json.dev.js +++ b/dist/pretty-print-json.dev.js @@ -1,7 +1,7 @@ -//! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v2.1.1 ~~ https://pretty-print-json.js.org ~~ MIT License const prettyPrintJson = { - version: '2.1.0', + version: '2.1.1', toHtml(data, options) { if (!''.at) String.prototype.at = function (i) { return this.charAt(i + (i < 0 ? this.length : 0)); }; diff --git a/dist/pretty-print-json.js b/dist/pretty-print-json.js index 2257ca4..79dcc87 100644 --- a/dist/pretty-print-json.js +++ b/dist/pretty-print-json.js @@ -1,7 +1,7 @@ -//! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v2.1.1 ~~ https://pretty-print-json.js.org ~~ MIT License const prettyPrintJson = { - version: '2.1.0', + version: '2.1.1', toHtml(data, options) { if (!''.at) String.prototype.at = function (i) { return this.charAt(i + (i < 0 ? this.length : 0)); }; diff --git a/dist/pretty-print-json.min.js b/dist/pretty-print-json.min.js index d88ef73..d9521bb 100644 --- a/dist/pretty-print-json.min.js +++ b/dist/pretty-print-json.min.js @@ -1,2 +1,2 @@ -//! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License -const prettyPrintJson={version:"2.1.0",toHtml(data,options){if(!"".at)String.prototype.at=function(i){return this.charAt(i+(i<0?this.length:0))};if(options?.["trailingComma"]!==undefined)options.trailingCommas=options["trailingComma"];const defaults={indent:3,lineNumbers:false,linkUrls:true,linksNewTab:true,quoteKeys:false,trailingCommas:true};const settings={...defaults,...options};const invalidHtml=/[<>&]|\\"/g;const toHtml=char=>char==="<"?"<":char===">"?">":char==="&"?"&":"\"";const spanTag=(type,display)=>display?""+display+"":"";const buildValueHtml=value=>{const strType=/^"/.test(value)&&"string";const boolType=["true","false"].includes(value)&&"boolean";const nullType=value==="null"&&"null";const type=boolType||nullType||strType||"number";const urlPattern=/https?:\/\/[^\s"]+/g;const target=settings.linksNewTab?" target=_blank":"";const makeLink=link=>`${link}`;const display=strType&&settings.linkUrls?value.replace(urlPattern,makeLink):value;return spanTag(type,display)};const replacer=(match,...parts)=>{const part={indent:parts[0],key:parts[1],value:parts[2],end:parts[3]};const findName=settings.quoteKeys?/(.*)(): /:/"([\w$]+)": |(.*): /;const indentHtml=part.indent||"";const keyName=part.key&&part.key.replace(findName,"$1$2");const keyHtml=part.key?spanTag("key",keyName)+spanTag("mark",": "):"";const valueHtml=part.value?buildValueHtml(part.value):"";const noComma=!part.end||["]","}"].includes(match.at(-1));const addComma=settings.trailingCommas&&match.at(0)===" "&&noComma;const endHtml=spanTag("mark",addComma?(part.end??"")+",":part.end);return indentHtml+keyHtml+valueHtml+endHtml};const jsonLine=/^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/gm;const json=JSON.stringify(data,null,settings.indent)||"undefined";const html=json.replace(invalidHtml,toHtml).replace(jsonLine,replacer);const makeLine=line=>`
  • ${line}
  • `;const addLineNumbers=html=>["
      ",...html.split("\n").map(makeLine),"
    "].join("\n");return settings.lineNumbers?addLineNumbers(html):html}};globalThis.prettyPrintJson=prettyPrintJson; +//! pretty-print-json v2.1.1 ~~ https://pretty-print-json.js.org ~~ MIT License +const prettyPrintJson={version:"2.1.1",toHtml(data,options){if(!"".at)String.prototype.at=function(i){return this.charAt(i+(i<0?this.length:0))};if(options?.["trailingComma"]!==undefined)options.trailingCommas=options["trailingComma"];const defaults={indent:3,lineNumbers:false,linkUrls:true,linksNewTab:true,quoteKeys:false,trailingCommas:true};const settings={...defaults,...options};const invalidHtml=/[<>&]|\\"/g;const toHtml=char=>char==="<"?"<":char===">"?">":char==="&"?"&":"\"";const spanTag=(type,display)=>display?""+display+"":"";const buildValueHtml=value=>{const strType=/^"/.test(value)&&"string";const boolType=["true","false"].includes(value)&&"boolean";const nullType=value==="null"&&"null";const type=boolType||nullType||strType||"number";const urlPattern=/https?:\/\/[^\s"]+/g;const target=settings.linksNewTab?" target=_blank":"";const makeLink=link=>`${link}`;const display=strType&&settings.linkUrls?value.replace(urlPattern,makeLink):value;return spanTag(type,display)};const replacer=(match,...parts)=>{const part={indent:parts[0],key:parts[1],value:parts[2],end:parts[3]};const findName=settings.quoteKeys?/(.*)(): /:/"([\w$]+)": |(.*): /;const indentHtml=part.indent||"";const keyName=part.key&&part.key.replace(findName,"$1$2");const keyHtml=part.key?spanTag("key",keyName)+spanTag("mark",": "):"";const valueHtml=part.value?buildValueHtml(part.value):"";const noComma=!part.end||["]","}"].includes(match.at(-1));const addComma=settings.trailingCommas&&match.at(0)===" "&&noComma;const endHtml=spanTag("mark",addComma?(part.end??"")+",":part.end);return indentHtml+keyHtml+valueHtml+endHtml};const jsonLine=/^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/gm;const json=JSON.stringify(data,null,settings.indent)||"undefined";const html=json.replace(invalidHtml,toHtml).replace(jsonLine,replacer);const makeLine=line=>`
  • ${line}
  • `;const addLineNumbers=html=>["
      ",...html.split("\n").map(makeLine),"
    "].join("\n");return settings.lineNumbers?addLineNumbers(html):html}};globalThis.prettyPrintJson=prettyPrintJson; diff --git a/dist/pretty-print-json.umd.cjs b/dist/pretty-print-json.umd.cjs index 95f1597..a48cb40 100644 --- a/dist/pretty-print-json.umd.cjs +++ b/dist/pretty-print-json.umd.cjs @@ -1,4 +1,4 @@ -//! pretty-print-json v2.1.0 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v2.1.1 ~~ 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: '2.1.0', + version: '2.1.1', toHtml(data, options) { if (!''.at) String.prototype.at = function (i) { return this.charAt(i + (i < 0 ? this.length : 0)); }; diff --git a/docs/dynamic/index.html b/docs/dynamic/index.html index d1afb0c..d12a84f 100644 --- a/docs/dynamic/index.html +++ b/docs/dynamic/index.html @@ -14,7 +14,7 @@ - + - + - + + - +