feat(new tool): XML Linter

Fix #1408
This commit is contained in:
ShareVB committed 2025-08-20 19:20:34 +02:00
1 parent 1f314da094
commit 03e6e208ec
4 files changed
+80

No files matched your search

+1
View File
@@ -138,6 +138,7 @@
"exif-be-gone": "^1.5.1",
"exifreader": "^4.26.1",
"fanger": "^0.3.1",
"fast-xml-parser": "^5.2.5",
"fast_array_intersect": "^1.1.0",
"fflate": "^0.8.2",
"figlet": "^1.8.2",
+14
View File
@@ -302,6 +302,9 @@ dependencies:
fanger:
specifier: ^0.3.1
version: 0.3.1
fast-xml-parser:
specifier: ^5.2.5
version: 5.2.5
fast_array_intersect:
specifier: ^1.1.0
version: 1.1.0
@@ -11260,6 +11263,13 @@ packages:
/fast-uri@3.0.6:
resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==}
/fast-xml-parser@5.2.5:
resolution: {integrity: sha512-pfX9uG9Ki0yekDHx2SiuRIyFdyAr1kMIMitPvb0YBo8SUfKvia7w7FIyd/l6av85pFYRhZscS75MwMnbvY+hcQ==}
hasBin: true
dependencies:
strnum: 2.1.1
dev: false
/fast_array_intersect@1.1.0:
resolution: {integrity: sha512-/DCilZlUdz2XyNDF+ASs0PwY+RKG9Y4Silp/gbS72Cvbg4oibc778xcecg+pnNyiNHYgh/TApsiDTjpdniyShw==}
dev: false
@@ -17025,6 +17035,10 @@ packages:
dependencies:
acorn: 8.14.0
/strnum@2.1.1:
resolution: {integrity: sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==}
dev: false
/strtok3@10.3.2:
resolution: {integrity: sha512-or9w505RhhY66+uoe5YOC5QO/bRuATaoim3XTh+pGKx5VMWi/HDhMKuCjDLsLJouU2zg9Hf1nLPcNW7IHv80kQ==}
engines: {node: '>=18'}
+13
View File
@@ -0,0 +1,13 @@
import { Code } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'XML Linter',
path: '/xml-linter',
description: 'Lint XML content for syntax error',
keywords: ['xml', 'linter'],
component: () => import('./xml-linter.vue'),
icon: Code,
createdAt: new Date('2025-08-15'),
category: 'XML',
});
+52
View File
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { XMLParser } from 'fast-xml-parser';
const parser = new XMLParser();
const xmlContent = ref('');
const lintErrors = computed(() => {
const xml = xmlContent.value?.trim();
try {
if (xml) {
parser.parse(xml, true);
}
return '';
}
catch (e: any) {
return e.toString().trim();
}
});
const MONACO_EDITOR_OPTIONS = {
automaticLayout: true,
formatOnType: true,
formatOnPaste: true,
};
</script>
<template>
<div>
<n-card title="Your XML Content:" mb-2>
<div relative w-full>
<c-monaco-editor
v-model:value="xmlContent"
theme="vs-dark"
height="250px"
language="xml"
:options="MONACO_EDITOR_OPTIONS"
/>
</div>
</n-card>
<div v-if="lintErrors">
<n-alert type="error" title="Linting Error" :show-icon="true">
<pre>{{ lintErrors }}</pre>
</n-alert>
</div>
<div v-else-if="xmlContent">
<n-alert type="success" title="Valid XML" :show-icon="true">
No errors found. Your XML is valid!
</n-alert>
</div>
</div>
</template>