Skip to content

Commit a5a1252

Browse files
committed
Format/comment
1 parent 51ede64 commit a5a1252

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

src/jsonformatter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function valueToHTML(value: any, path: string, indent: number) {
9393
return decorateWithSpan(Number(value.slice(1)), "num");
9494
} else if (/^(http|https|file):\/\/[^\s]+$/i.test(value)) {
9595
return `<a href="${htmlEncode(value)}"><span class="q">&quot;</span>${jsString(
96-
value
96+
value,
9797
)}<span class="q">&quot;</span></a>`;
9898
} else {
9999
return `<span class="string">&quot;${jsString(value)}&quot;</span>`;
@@ -148,7 +148,7 @@ function objectToHTML(json: Record<string, unknown>, path: string, indent: numbe
148148
output += `<li>${addIndent(indent + 1)}<span class="prop${
149149
bare ? "" : " quoted"
150150
}" title="${htmlEncode(subPath)}"><span class="q">&quot;</span>${jsString(
151-
prop
151+
prop,
152152
)}<span class="q">&quot;</span></span>: ${valueToHTML(json[prop], subPath, indent + 1)}`;
153153
if (numProps > 1) {
154154
output += ",";
@@ -158,7 +158,7 @@ function objectToHTML(json: Record<string, unknown>, path: string, indent: numbe
158158
}
159159

160160
return `<span class="collapser"></span>{<ul class="obj collapsible">${output}</ul>${addIndent(
161-
indent
161+
indent,
162162
)}}`;
163163
}
164164

@@ -199,9 +199,9 @@ function highlightError(data: string, lineNum?: number, columnNum?: number) {
199199
if (i === lineNum - 1) {
200200
output += '<span class="errorline">';
201201
output += `${htmlEncode(
202-
line.substring(0, columnNum - 1)
202+
line.substring(0, columnNum - 1),
203203
)}<span class="errorcolumn">${htmlEncode(line[columnNum - 1])}</span>${htmlEncode(
204-
line.substring(columnNum)
204+
line.substring(columnNum),
205205
)}`;
206206
output += "</span>";
207207
} else {

src/viewer.css

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ body {
1111
}
1212

1313
.null {
14-
color: #A52A2A;
14+
color: #a52a2a;
1515
}
1616

1717
.bool {
@@ -30,10 +30,10 @@ body {
3030
.collapser {
3131
position: absolute;
3232
left: -1em;
33-
top: -.2em;
33+
top: -0.2em;
3434
cursor: pointer;
3535
transform: rotate(90deg);
36-
transition: transform .2s;
36+
transition: transform 0.2s;
3737
}
3838

3939
.collapser:before {
@@ -53,7 +53,7 @@ body {
5353
.collapsible.collapsed:before {
5454
content: "…";
5555
width: 1em;
56-
margin-left: .2em;
56+
margin-left: 0.2em;
5757
}
5858

5959
.collapser.collapsed {
@@ -81,12 +81,12 @@ li {
8181
border-bottom: 1px solid rgb(212, 209, 209);
8282
background-color: rgb(239, 239, 239);
8383
margin-bottom: 1.5em;
84-
padding: 1em .5em;
84+
padding: 1em 0.5em;
8585
}
8686

8787
.errormessage {
8888
font-family: monospace;
89-
margin-top: .5em;
89+
margin-top: 0.5em;
9090
color: rgb(167, 5, 5);
9191
}
9292

@@ -96,14 +96,14 @@ li {
9696
}
9797

9898
.errorline {
99-
background-color: rgb(255, 226, 226);
99+
background-color: rgb(255, 226, 226);
100100
}
101101

102102
#json {
103103
font-family: monospace;
104104
font-size: 1.1em;
105105
white-space: pre-wrap;
106-
margin: .5em;
106+
margin: 0.5em;
107107
}
108108

109109
ul {
@@ -123,14 +123,14 @@ h1 {
123123

124124
.callback {
125125
font-family: monospace;
126-
color: #A52A2A;
126+
color: #a52a2a;
127127
}
128128

129129
/* Tomorrow Night theme */
130130
@media (prefers-color-scheme: dark) {
131131
body {
132-
background-color: #27292C;
133-
color: #D7DAD8;
132+
background-color: #27292c;
133+
color: #d7dad8;
134134
}
135135

136136
a {
@@ -141,35 +141,35 @@ h1 {
141141
}
142142

143143
.bool {
144-
color: #92B2CA;
144+
color: #92b2ca;
145145
}
146146

147147
.num {
148-
color: #92B2CA;
148+
color: #92b2ca;
149149
}
150150

151151
.null {
152-
color: #D77C78;
152+
color: #d77c78;
153153
}
154154

155155
.callback {
156-
color: #D77C78;
156+
color: #d77c78;
157157
}
158158

159159
.string {
160-
color: #C2C77B;
160+
color: #c2c77b;
161161
}
162162

163163
#error {
164164
border-bottom: 1px solid rgb(61, 61, 61);
165165
background-color: rgb(37, 37, 37);
166166
margin-bottom: 1.5em;
167-
padding: 1em .5em;
167+
padding: 1em 0.5em;
168168
}
169169

170170
.errormessage {
171171
font-family: monospace;
172-
margin-top: .5em;
172+
margin-top: 0.5em;
173173
color: rgb(212, 10, 10);
174174
}
175175

@@ -179,7 +179,7 @@ h1 {
179179
}
180180

181181
.errorline {
182-
background-color: rgb(32, 29, 29);
182+
background-color: rgb(32, 29, 29);
183183
}
184184
}
185185

@@ -188,10 +188,13 @@ h1 {
188188
width: 0px;
189189
}
190190

191-
.string, :any-link {
191+
/* Allow long URLs to break */
192+
.string,
193+
:any-link {
192194
word-break: break-all;
193195
}
194196

197+
/* Prevent double-highlighting of spacers */
195198
:is(.spacer, :not(.quoted) > .q)::selection {
196199
background-color: transparent;
197200
}

0 commit comments

Comments
 (0)