From f44de39be5cbabdc8f5eaddbfc40175597f7ed35 Mon Sep 17 00:00:00 2001 From: Martin Leduc <31558169+DecimalTurn@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:20:41 -0400 Subject: [PATCH 1/4] Add JSONC validator functionality and styles to index.markdown and style.scss --- assets/css/style.scss | 120 +++++++++++++++++++++++++++++++++++++++++- index.markdown | 110 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 228 insertions(+), 2 deletions(-) diff --git a/assets/css/style.scss b/assets/css/style.scss index f500ff8..c4e0f66 100644 --- a/assets/css/style.scss +++ b/assets/css/style.scss @@ -1,7 +1,7 @@ --- --- -@import 'jekyll-theme-cayman'; +@import "jekyll-theme-cayman"; /* Custom Highlight.js Styles */ .hljs-error { @@ -10,4 +10,120 @@ background-color: rgba(255, 0, 0, 0.2); border-radius: 3px; padding: 2px 4px; - } \ No newline at end of file +} + +/* JSONC Validator Styles */ +.jsonc-validator { + margin: 2rem 0; + padding: 1.5rem; + border: 2px solid #e1e4e8; + border-radius: 8px; + background-color: #f8f9fa; +} + +.jsonc-validator textarea { + width: 100%; + min-height: 200px; + padding: 1rem; + border: 1px solid #d1d5da; + border-radius: 6px; + font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 14px; + line-height: 1.45; + background-color: #ffffff; + resize: vertical; + box-sizing: border-box; +} + +.jsonc-validator textarea:focus { + outline: none; + border-color: #0366d6; + box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1); +} + +.validator-controls { + margin: 1rem 0; + display: flex; + gap: 0.5rem; +} + +.validator-controls button { + padding: 0.75rem 1.5rem; + border: none; + border-radius: 6px; + font-size: 14px; + font-weight: 500; + cursor: pointer; + transition: all 0.2s ease; +} + +#validate-btn { + background-color: #28a745; + color: white; +} + +#validate-btn:hover { + background-color: #218838; +} + +#validate-btn:disabled { + background-color: #6c757d; + cursor: not-allowed; +} + +#clear-btn { + background-color: #6c757d; + color: white; +} + +#clear-btn:hover { + background-color: #5a6268; +} + +.validation-result { + margin-top: 1rem; + padding: 1rem; + border-radius: 6px; + min-height: 50px; +} + +.validation-result .success { + background-color: #d4edda; + border: 1px solid #c3e6cb; + color: #155724; + padding: 1rem; + border-radius: 6px; +} + +.validation-result .error { + background-color: #f8d7da; + border: 1px solid #f5c6cb; + color: #721c24; + padding: 1rem; + border-radius: 6px; +} + +.validation-result details { + margin-top: 1rem; +} + +.validation-result summary { + cursor: pointer; + font-weight: 500; + margin-bottom: 0.5rem; +} + +.validation-result pre { + background-color: #f6f8fa; + border: 1px solid #e1e4e8; + border-radius: 6px; + padding: 1rem; + overflow-x: auto; + font-size: 12px; + margin: 0; +} + +.validation-result code { + background-color: transparent; + padding: 0; +} \ No newline at end of file diff --git a/index.markdown b/index.markdown index 3d5b81f..d3456d0 100644 --- a/index.markdown +++ b/index.markdown @@ -68,6 +68,116 @@ or - Configuration Files: JSONC is useful for configuration files where comments can provide explanations or instructions. - Data Annotation: JSONC allows developers to annotate JSON data with comments for better understanding and maintenance. +## JSONC Validator + +Try out JSONC validation directly in your browser: + +
+ + +
+ + +
+ +
+
+ + + + ## Tools and Libraries Several tools and libraries support JSONC, enabling developers to parse and generate JSONC data easily. From 5dac9c33ff218020d92a8cc48e12329f14238a86 Mon Sep 17 00:00:00 2001 From: Martin Leduc <31558169+DecimalTurn@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:59:47 -0400 Subject: [PATCH 2/4] Fix var name --- index.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.markdown b/index.markdown index d3456d0..b0bed76 100644 --- a/index.markdown +++ b/index.markdown @@ -108,7 +108,7 @@ function validateJSONC() { try { // Parse the JSONC using microsoft/node-jsonc-parser const parseErrors = []; - const parsed = jsoncParser.parse(jsoncText, parseErrors); + const parsed = jsonc.parse(jsoncText, parseErrors); if (parseErrors.length > 0) { let errorMessages = parseErrors.map(error => { From c69b3fda8a817aeb77658d1c2eeb705acfc9ab80 Mon Sep 17 00:00:00 2001 From: Martin Leduc <31558169+DecimalTurn@users.noreply.github.com> Date: Thu, 26 Jun 2025 00:16:55 -0400 Subject: [PATCH 3/4] Refactor JSONC validation script to use ES module --- index.markdown | 51 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/index.markdown b/index.markdown index b0bed76..d52c4e9 100644 --- a/index.markdown +++ b/index.markdown @@ -88,9 +88,14 @@ Try out JSONC validation directly in your browser:
- +