Skip to content

Commit 7616a35

Browse files
committed
feat(new tool): HTML Prettier
HTML Prettier
1 parent a7dd503 commit 7616a35

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script setup lang="ts">
2+
import beautify from 'js-beautify';
3+
import TextareaCopyable from '@/components/TextareaCopyable.vue';
4+
5+
const inputHtml = ref('');
6+
const outputHtml = computed(() => {
7+
return beautify.html(inputHtml.value, {
8+
unformatted: ['code', 'pre', 'em', 'strong', 'span'],
9+
indent_inner_html: true,
10+
indent_char: ' ',
11+
indent_size: 2,
12+
sep: '\n',
13+
});
14+
});
15+
</script>
16+
17+
<template>
18+
<div>
19+
<c-input-text
20+
v-model:value="inputHtml"
21+
multiline raw-text
22+
placeholder="Your HTML content..."
23+
rows="8"
24+
autofocus
25+
label="Your HTML to format (can paste from clipboard):"
26+
paste-html
27+
/>
28+
29+
<n-divider />
30+
31+
<n-form-item label="Output prettified HTML:">
32+
<TextareaCopyable
33+
:value="outputHtml"
34+
multiline
35+
language="html"
36+
:word-wrap="true"
37+
/>
38+
</n-form-item>
39+
</div>
40+
</template>

src/tools/html-prettifier/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { BrandHtml5 } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Html Prettifier',
6+
path: '/html-prettifier',
7+
description: 'Prettify HTML code',
8+
keywords: ['html', 'prettifier', 'beautify', 'prettier', 'format'],
9+
component: () => import('./html-prettifier.vue'),
10+
icon: BrandHtml5,
11+
createdAt: new Date('2024-03-15'),
12+
});

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
77
import { tool as textToUnicode } from './text-to-unicode';
88
import { tool as safelinkDecoder } from './safelink-decoder';
99
import { tool as cssPrettifier } from './css-prettifier';
10+
import { tool as htmlPrettifier } from './html-prettifier';
1011
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
1112
import { tool as numeronymGenerator } from './numeronym-generator';
1213
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -150,6 +151,7 @@ export const toolsByCategory: ToolCategory[] = [
150151
xmlFormatter,
151152
yamlViewer,
152153
cssPrettifier,
154+
htmlPrettifier,
153155
],
154156
},
155157
{

0 commit comments

Comments
 (0)