From 32fca73d3adb9a6c49c38031addf8ffbc3f19b32 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 4 Jun 2026 17:01:36 -0500 Subject: [PATCH] Fix JSON punctuation highlighting inside string values --- lib/aprsme_web/live/api_docs_live.ex | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/aprsme_web/live/api_docs_live.ex b/lib/aprsme_web/live/api_docs_live.ex index b5c8793..f4ef13b 100644 --- a/lib/aprsme_web/live/api_docs_live.ex +++ b/lib/aprsme_web/live/api_docs_live.ex @@ -209,29 +209,29 @@ defmodule AprsmeWeb.ApiDocsLive do defp sanitize_raw_packet(raw_packet), do: raw_packet defp highlight_json(text) do - highlighted = - Regex.replace( - ~r/(? - ~s(#{key}) + Regex.replace( + ~r/(? + ~s(#{key}) - _, "", str, "", "", "" -> - ~s(#{str}) + _, "", str, "", "", "", "" -> + ~s(#{str}) - _, "", "", bool, "", "" -> - ~s(#{bool}) + _, "", "", bool, "", "", "" -> + ~s(#{bool}) - _, "", "", "", null, "" -> - ~s(#{null}) + _, "", "", "", null, "", "" -> + ~s(#{null}) - _, "", "", "", "", num -> - ~s(#{num}) - end - ) + _, "", "", "", "", num, "" -> + ~s(#{num}) - Regex.replace(~r/[{}[\]\:,]/, highlighted, ~s(\\0)) + _, "", "", "", "", "", punc -> + ~s(#{punc}) + end + ) end defp callsign_success_json, do: ~s|{