Skip to content

Commit cfffce4

Browse files
committed
Hocon + XML + Fixes
1 parent 7097582 commit cfffce4

File tree

9 files changed

+109
-6
lines changed

9 files changed

+109
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ It currently includes the following features:
1212
- [Yaml Config Validator](https://toolbox.helpch.at/validators/yaml)
1313
- [Properties Config Validator](https://toolbox.helpch.at/validators/properties)
1414
- [Toml Config Validator](https://toolbox.helpch.at/validators/toml)
15+
- [Hocon Config Validator](https://toolbox.helpch.at/validators/hocon)
16+
- [XML Config Validator](https://toolbox.helpch.at/validators/xml)
1517

1618
### Usage
1719

components/TextBox.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
88
import "prismjs/components/prism-yaml";
99
import "prismjs/components/prism-toml";
1010
import "prismjs/components/prism-properties";
11+
import "prismjs/components/prism-json";
12+
import "prismjs/components/prism-xml-doc";
1113

1214
const textBoxStyle = tw`flex-grow flex-shrink border-none outline-none focus:outline-none max-h-full`;
1315

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@fortawesome/free-solid-svg-icons": "^6.1.0",
1616
"@fortawesome/react-fontawesome": "^0.1.18",
1717
"@js.properties/properties": "^0.5.4",
18+
"@tkint/hocon-parser": "^0.0.0-alpha.0",
1819
"ajv": "^8.10.0",
1920
"next": "12.1.0",
2021
"prism-react-renderer": "^1.3.1",
@@ -25,6 +26,8 @@
2526
"react-simple-code-editor": "^0.11.0",
2627
"styled-components": "^5.3.3",
2728
"toml": "^3.0.0",
29+
"x2js": "^3.4.3",
30+
"xml-js": "^1.6.11",
2831
"yaml": "^2.0.0-10"
2932
},
3033
"devDependencies": {

pages/_app.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,25 @@ function Toolbox({ Component, pageProps }: AppProps) {
114114
</p>
115115
</Link>
116116
<Link href={"/validators/properties"}>
117-
<p css={tw`px-2 mx-1 ml-3 hover:cursor-pointer pb-2`}>
117+
<p css={tw`px-2 mx-1 ml-3 hover:cursor-pointer pb-1`}>
118118
Properties
119119
</p>
120120
</Link>
121121
<Link href={"/validators/toml"}>
122-
<p css={tw`px-2 mx-1 ml-3 hover:cursor-pointer pb-2`}>
122+
<p css={tw`px-2 mx-1 ml-3 hover:cursor-pointer pb-1`}>
123123
Toml
124124
</p>
125125
</Link>
126+
<Link href={"/validators/hocon"}>
127+
<p css={tw`px-2 mx-1 ml-3 hover:cursor-pointer pb-1`}>
128+
Hocon
129+
</p>
130+
</Link>{" "}
131+
<Link href={"/validators/xml"}>
132+
<p css={tw`px-2 mx-1 ml-3 hover:cursor-pointer pb-1`}>
133+
XML
134+
</p>
135+
</Link>
126136
</div>
127137
</div>
128138
<Link href={"https://discord.gg/helpchat"}>

pages/validators/hocon.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { NextPage } from "next";
2+
import { parseHocon as parse } from "@tkint/hocon-parser";
3+
import Validator from "../../components/Validator";
4+
5+
const HoconValidator: NextPage = () => (
6+
<Validator
7+
language={"Hocon"}
8+
lang={"yaml"}
9+
parser={(config) => {
10+
let configObject;
11+
try {
12+
configObject = parse(config);
13+
if (!configObject || !(typeof configObject === "object")) {
14+
return { error: true, message: "must be object" };
15+
} else {
16+
return {
17+
error: false,
18+
data: configObject,
19+
};
20+
}
21+
} catch (e: any) {
22+
return { error: true, message: e.message };
23+
}
24+
}}
25+
/>
26+
);
27+
28+
export default HoconValidator;

pages/validators/properties.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { NextPage } from "next";
22
import Properties from "@js.properties/properties";
33
import Validator from "../../components/Validator";
44

5-
const TomlValidator: NextPage = () => (
5+
const PropertiesValidator: NextPage = () => (
66
<Validator
77
language={"Properties"}
88
lang={"properties"}
@@ -27,4 +27,4 @@ const TomlValidator: NextPage = () => (
2727
/>
2828
);
2929

30-
export default TomlValidator;
30+
export default PropertiesValidator;

pages/validators/xml.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { NextPage } from "next";
2+
import { xml2json as parse } from "xml-js";
3+
import Validator from "../../components/Validator";
4+
5+
const XMLValidator: NextPage = () => (
6+
<Validator
7+
language={"XML"}
8+
lang={"xml"}
9+
parser={(config) => {
10+
try {
11+
const configObject = JSON.parse(parse(config, { compact: true }));
12+
console.log(configObject);
13+
if (!configObject || !(typeof configObject === "object")) {
14+
return { error: true, message: "must be object" };
15+
} else {
16+
return {
17+
error: false,
18+
data: configObject,
19+
};
20+
}
21+
} catch (e: any) {
22+
console.log(e);
23+
return { error: true, message: e.message };
24+
}
25+
}}
26+
/>
27+
);
28+
29+
export default XMLValidator;

pages/validators/yaml.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { NextPage } from "next";
22
import { parse } from "yaml";
33
import Validator from "../../components/Validator";
44

5-
const TomlValidator: NextPage = () => (
5+
const YamlValidator: NextPage = () => (
66
<Validator
77
language={"Yaml"}
88
lang={"yaml"}
@@ -25,4 +25,4 @@ const TomlValidator: NextPage = () => (
2525
/>
2626
);
2727

28-
export default TomlValidator;
28+
export default YamlValidator;

yarn.lock

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@
328328
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.1.1.tgz#782fa5da44c4f38ae9fd38e9184b54e451936118"
329329
integrity sha512-BUyKJGdDWqvWC5GEhyOiUrGNi9iJUr4CU0O2WxJL6QJhHeeA/NVBalH+FeK0r/x/W0rPymXt5s78TDS7d6lCwg==
330330

331+
"@tkint/hocon-parser@^0.0.0-alpha.0":
332+
version "0.0.0-alpha.0"
333+
resolved "https://registry.yarnpkg.com/@tkint/hocon-parser/-/hocon-parser-0.0.0-alpha.0.tgz#45dcb8bd22acff19693a032d303e4f21db59c03b"
334+
integrity sha512-OVh5fGPxJ78+UYjcMy7O69M1N24IqD7q5XPq/JMtxjIjLDjUT9GyGp+fay1vVzpQmuT6HR7kGhpGbkGmw+F8Fg==
335+
331336
"@tsconfig/node10@^1.0.7":
332337
version "1.0.8"
333338
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
@@ -453,6 +458,11 @@
453458
"@typescript-eslint/types" "5.15.0"
454459
eslint-visitor-keys "^3.0.0"
455460

461+
"@xmldom/xmldom@^0.7.4":
462+
version "0.7.5"
463+
resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.7.5.tgz#09fa51e356d07d0be200642b0e4f91d8e6dd408d"
464+
integrity sha512-V3BIhmY36fXZ1OtVcI9W+FxQqxVLsPKcNjWigIaa81dLC9IolJl5Mt4Cvhmr0flUnjSpTdrbMTSbXqYqV5dT6A==
465+
456466
acorn-jsx@^5.3.1:
457467
version "5.3.2"
458468
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
@@ -2447,6 +2457,11 @@ safe-stable-stringify@^2.3.1:
24472457
resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz#ab67cbe1fe7d40603ca641c5e765cb942d04fc73"
24482458
integrity sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg==
24492459

2460+
sax@^1.2.4:
2461+
version "1.2.4"
2462+
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
2463+
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
2464+
24502465
scheduler@^0.20.2:
24512466
version "0.20.2"
24522467
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91"
@@ -2919,6 +2934,20 @@ wrappy@1:
29192934
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
29202935
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
29212936

2937+
x2js@^3.4.3:
2938+
version "3.4.3"
2939+
resolved "https://registry.yarnpkg.com/x2js/-/x2js-3.4.3.tgz#3f57537302ff269ad7043078188bb07bc8088af9"
2940+
integrity sha512-+65+WHCaQ9E0Gb2FDz/tYRSRBGGvFsSMiWDGn8KbgJOLkJhZBMCU1lxuRMLyTcx/54IopT0rDQWCUz2f7FTsyQ==
2941+
dependencies:
2942+
"@xmldom/xmldom" "^0.7.4"
2943+
2944+
xml-js@^1.6.11:
2945+
version "1.6.11"
2946+
resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.11.tgz#927d2f6947f7f1c19a316dd8eea3614e8b18f8e9"
2947+
integrity sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==
2948+
dependencies:
2949+
sax "^1.2.4"
2950+
29222951
xtend@^4.0.2:
29232952
version "4.0.2"
29242953
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"

0 commit comments

Comments
 (0)