File tree Expand file tree Collapse file tree 1 file changed +0
-45
lines changed
Expand file tree Collapse file tree 1 file changed +0
-45
lines changed Original file line number Diff line number Diff line change @@ -230,51 +230,6 @@ document.addEventListener('DOMContentLoaded', function () {
230230 }
231231} ) ;
232232
233- /**
234- * JSON syntax highlighter
235- */
236- const json_syntax_highlight = ( json ) => {
237- if ( typeof json !== 'string' ) {
238- json = JSON . stringify ( json , null , 2 ) ;
239- }
240-
241- json = json . replace ( / & / g, '&' )
242- . replace ( / < / g, '<' )
243- . replace ( / > / g, '>' ) ;
244-
245- return json . replace (
246- / ( " ( \\ u [ a - z A - Z 0 - 9 ] { 4 } | \\ [ ^ u ] | [ ^ \\ " ] ) * " ( \s * : ) ? | \b ( t r u e | f a l s e | n u l l ) \b | - ? \d + (?: \. \d * ) ? (?: [ e E ] [ + - ] ? \d + ) ? | [ { } \[ \] , : ] ) / g,
247- match => {
248- let cls = '' ;
249- if ( / ^ " / . test ( match ) ) {
250- if ( / : $ / . test ( match ) ) {
251- cls = 'json-key' ;
252- } else {
253- cls = 'json-string' ;
254- }
255- } else if ( / t r u e | f a l s e / . test ( match ) ) {
256- cls = 'json-boolean' ;
257- } else if ( / n u l l / . test ( match ) ) {
258- cls = 'json-null' ;
259- } else if ( / ^ - ? \d + (?: \. \d + ) ? (?: [ e E ] [ + - ] ? \d + ) ? $ / . test ( match ) ) {
260- cls = 'json-number' ;
261- } else if ( / [ \[ \] { } ] / . test ( match ) ) {
262- cls = 'json-bracket' ;
263- } else if ( match === ',' ) {
264- cls = 'json-comma' ;
265- } else if ( match === ':' ) {
266- cls = 'json-colon' ;
267- }
268-
269- return cls ? `<span class="${ cls } ">${ match } </span>` : match ;
270- }
271- ) ;
272- } ;
273-
274- document . querySelectorAll ( '.json-code' ) . forEach ( value => {
275- value . innerHTML = json_syntax_highlight ( value . textContent ) ;
276- } ) ;
277-
278233/**
279234 * Redirects
280235 */
You can’t perform that action at this time.
0 commit comments