From 2a73e2033bdb8dacf3da9b05cee9184d2c4a23b3 Mon Sep 17 00:00:00 2001 From: dpilafian Date: Wed, 14 Aug 2024 10:16:06 -0700 Subject: [PATCH] Release v3.0.2 --- README.md | 9 +++++++-- dist/css/pretty-print-json.css | 13 ++++++++++--- dist/css/pretty-print-json.dark-mode.css | 13 ++++++++++--- dist/css/pretty-print-json.dark-mode.min.css | 4 ++-- dist/css/pretty-print-json.min.css | 4 ++-- dist/css/pretty-print-json.prefers.css | 11 ++++++++--- dist/css/pretty-print-json.prefers.min.css | 4 ++-- 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 ++-- docs/dynamic/index.html | 6 +++--- docs/index.html | 2 +- package.json | 4 ++-- spec/dynamic.html | 6 +++--- spec/interactive.html | 2 +- 16 files changed, 58 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 38a0a07..4626c3b 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,12 @@ Example TypeScript usage with explicit types: ```typescript import { prettyPrintJson, FormatOptions } from 'pretty-print-json'; -const data = { active: true, mode: '🚃', codes: [48348, 28923, 39080], city: 'London' }; +const data = { + active: true, + mode: '🚃', + codes: [48348, 28923, 39080], + city: 'London', + }; const options: FormatOptions = { linkUrls: true }; const html: string = prettyPrintJson.toHtml(data, options); ``` @@ -111,7 +116,7 @@ interesting approach to organizing build tasks. - 🪺 [recursive-exec](https://github.com/center-key/recursive-exec):  _Run a command on each file in a folder and its subfolders_ - 🔍 [replacer-util](https://github.com/center-key/replacer-util):  _Find and replace strings or template outputs in text files_ - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):  _Revision web asset filenames with cache busting content hash fingerprints_ - - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):  _Organize npm package.json scripts into named groups of easy to manage commands_ + - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):  _Organize npm package.json scripts into groups of easy to manage commands_ - 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):  _Check the markup validity of HTML files using the W3C validator_
diff --git a/dist/css/pretty-print-json.css b/dist/css/pretty-print-json.css index cde82d7..273bb9e 100644 --- a/dist/css/pretty-print-json.css +++ b/dist/css/pretty-print-json.css @@ -1,4 +1,4 @@ -/*! pretty-print-json v3.0.1 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v3.0.2 ~~ 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; } @@ -9,6 +9,13 @@ ol.json-lines >li { white-space: pre; text-indent: 0.7em; line-height: 1 ol.json-lines >li::marker { font-family: system-ui, sans-serif; font-weight: normal; } .json-key, .json-string, .json-number, .json-boolean, .json-null, .json-mark, a.json-link, ol.json-lines >li { transition: all 400ms; } +/* Custom Colors */ +ol.json-lines { + --colorGraphite: #303030; + --colorCharcoal: #222222; + --colorTar: #161616; + } + /* Colors */ .json-container { background-color: white; } .json-key { color: brown; } @@ -39,6 +46,6 @@ ol.json-lines >li:hover { background-color: lemonchiffon; } .dark-mode a.json-link:hover { color: violet; } .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; } +.dark-mode ol.json-lines >li:nth-child(odd) { background-color: var(--colorCharcoal); } +.dark-mode ol.json-lines >li:nth-child(even) { background-color: var(--colorTar); } .dark-mode ol.json-lines >li:hover { background-color: dimgray; } diff --git a/dist/css/pretty-print-json.dark-mode.css b/dist/css/pretty-print-json.dark-mode.css index 9492dfd..5af8232 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 v3.0.1 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v3.0.2 ~~ 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; } @@ -9,6 +9,13 @@ ol.json-lines >li { white-space: pre; text-indent: 0.7em; line-height: 1 ol.json-lines >li::marker { font-family: system-ui, sans-serif; font-weight: normal; } .json-key, .json-string, .json-number, .json-boolean, .json-null, .json-mark, a.json-link, ol.json-lines >li { transition: all 400ms; } +/* Custom Colors */ +ol.json-lines { + --colorGraphite: #303030; + --colorCharcoal: #222222; + --colorTar: #161616; + } + /* Dark Mode */ .json-container { background-color: black; } .json-key { color: indianred; } @@ -22,6 +29,6 @@ a.json-link:visited { color: slategray; } a.json-link:hover { color: violet; } 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; } +ol.json-lines >li:nth-child(odd) { background-color: var(--colorCharcoal); } +ol.json-lines >li:nth-child(even) { background-color: var(--colorTar); } ol.json-lines >li:hover { background-color: dimgray; } diff --git a/dist/css/pretty-print-json.dark-mode.min.css b/dist/css/pretty-print-json.dark-mode.min.css index 2775aa4..021afed 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 v3.0.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} +/*! pretty-print-json v3.0.2 ~~ 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;--colorGraphite:#303030;--colorCharcoal:#222222;--colorTar:#161616}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:var(--colorCharcoal)}ol.json-lines>li:nth-child(even){background-color:var(--colorTar)}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 ee87f8b..f0f529d 100644 --- a/dist/css/pretty-print-json.min.css +++ b/dist/css/pretty-print-json.min.css @@ -1,2 +1,2 @@ -/*! pretty-print-json v3.0.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} +/*! pretty-print-json v3.0.2 ~~ 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;--colorGraphite:#303030;--colorCharcoal:#222222;--colorTar:#161616}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:var(--colorCharcoal)}.dark-mode ol.json-lines>li:nth-child(even){background-color:var(--colorTar)}.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 ccf7398..2a46180 100644 --- a/dist/css/pretty-print-json.prefers.css +++ b/dist/css/pretty-print-json.prefers.css @@ -1,4 +1,4 @@ -/*! pretty-print-json v3.0.1 ~~ https://pretty-print-json.js.org ~~ MIT License */ +/*! pretty-print-json v3.0.2 ~~ 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; } @@ -28,6 +28,11 @@ ol.json-lines >li:hover { background-color: lemonchiffon; } /* Dark Mode */ @media (prefers-color-scheme: dark) { + ol.json-lines { + --colorGraphite: #303030; + --colorCharcoal: #222222; + --colorTar: #161616; + } .json-container { background-color: black; } .json-key { color: indianred; } .json-string { color: khaki; } @@ -40,7 +45,7 @@ ol.json-lines >li:hover { background-color: lemonchiffon; } a.json-link:hover { color: violet; } 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; } + ol.json-lines >li:nth-child(odd) { background-color: var(--colorCharcoal); } + ol.json-lines >li:nth-child(even) { background-color: var(--colorTar); } ol.json-lines >li:hover { background-color: dimgray; } } diff --git a/dist/css/pretty-print-json.prefers.min.css b/dist/css/pretty-print-json.prefers.min.css index 359c4c9..5408e4e 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 v3.0.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}} +/*! pretty-print-json v3.0.2 ~~ 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){ol.json-lines{--colorGraphite:#303030;--colorCharcoal:#222222;--colorTar:#161616}.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:var(--colorCharcoal)}ol.json-lines>li:nth-child(even){background-color:var(--colorTar)}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 e2f2a69..a27a782 100644 --- a/dist/pretty-print-json.d.ts +++ b/dist/pretty-print-json.d.ts @@ -1,4 +1,4 @@ -//! pretty-print-json v3.0.1 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v3.0.2 ~~ 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 922c5a6..eb33d66 100644 --- a/dist/pretty-print-json.dev.js +++ b/dist/pretty-print-json.dev.js @@ -1,7 +1,7 @@ -//! pretty-print-json v3.0.1 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v3.0.2 ~~ https://pretty-print-json.js.org ~~ MIT License const prettyPrintJson = { - version: '3.0.1', + version: '3.0.2', toHtml(data, options) { const defaults = { indent: 3, diff --git a/dist/pretty-print-json.js b/dist/pretty-print-json.js index bfa2410..f85595e 100644 --- a/dist/pretty-print-json.js +++ b/dist/pretty-print-json.js @@ -1,7 +1,7 @@ -//! pretty-print-json v3.0.1 ~~ https://pretty-print-json.js.org ~~ MIT License +//! pretty-print-json v3.0.2 ~~ https://pretty-print-json.js.org ~~ MIT License const prettyPrintJson = { - version: '3.0.1', + version: '3.0.2', toHtml(data, options) { const defaults = { indent: 3, diff --git a/dist/pretty-print-json.min.js b/dist/pretty-print-json.min.js index b8219a0..6077dfe 100644 --- a/dist/pretty-print-json.min.js +++ b/dist/pretty-print-json.min.js @@ -1,2 +1,2 @@ -//! pretty-print-json v3.0.1 ~~ https://pretty-print-json.js.org ~~ MIT License -const prettyPrintJson={version:"3.0.1",toHtml(data,options){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 v3.0.2 ~~ https://pretty-print-json.js.org ~~ MIT License +const prettyPrintJson={version:"3.0.2",toHtml(data,options){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/docs/dynamic/index.html b/docs/dynamic/index.html index b29a1ea..88c5e33 100644 --- a/docs/dynamic/index.html +++ b/docs/dynamic/index.html @@ -12,10 +12,10 @@ - + - + - + - +