Skip to content

Commit ccd6deb

Browse files
committed
feat(new tool): Markdown to HTML
Fix partially #538
1 parent a07806c commit ccd6deb

File tree

7 files changed

+98
-9
lines changed

7 files changed

+98
-9
lines changed

components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ declare module '@vue/runtime-core' {
129129
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
130130
MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default']
131131
MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default']
132+
MarkdownToHtml: typeof import('./src/tools/markdown-to-html/markdown-to-html.vue')['default']
132133
MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default']
133134
MenuBar: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar.vue')['default']
134135
MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default']

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@tiptap/pm": "2.1.6",
4242
"@tiptap/starter-kit": "2.1.6",
4343
"@tiptap/vue-3": "2.0.3",
44+
"@types/markdown-it": "^13.0.7",
4445
"@vicons/material": "^0.12.0",
4546
"@vicons/tabler": "^0.12.0",
4647
"@vueuse/core": "^10.3.0",
@@ -66,6 +67,7 @@
6667
"jwt-decode": "^3.1.2",
6768
"libphonenumber-js": "^1.10.28",
6869
"lodash": "^4.17.21",
70+
"markdown-it": "^14.0.0",
6971
"marked": "^10.0.0",
7072
"mathjs": "^11.9.1",
7173
"mime-types": "^2.1.35",

pnpm-lock.yaml

Lines changed: 50 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/TextareaCopyable.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
77
import xmlHljs from 'highlight.js/lib/languages/xml';
88
import yamlHljs from 'highlight.js/lib/languages/yaml';
99
import iniHljs from 'highlight.js/lib/languages/ini';
10+
import markdownHljs from 'highlight.js/lib/languages/markdown';
1011
import { useCopy } from '@/composable/copy';
1112
1213
const props = withDefaults(
@@ -30,6 +31,7 @@ hljs.registerLanguage('html', xmlHljs);
3031
hljs.registerLanguage('xml', xmlHljs);
3132
hljs.registerLanguage('yaml', yamlHljs);
3233
hljs.registerLanguage('toml', iniHljs);
34+
hljs.registerLanguage('markdown', markdownHljs);
3335
3436
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
3537
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
22
import { tool as base64StringConverter } from './base64-string-converter';
33
import { tool as basicAuthGenerator } from './basic-auth-generator';
44
import { tool as textToUnicode } from './text-to-unicode';
5+
import { tool as markdownToHtml } from './markdown-to-html';
56
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
67
import { tool as numeronymGenerator } from './numeronym-generator';
78
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -103,6 +104,7 @@ export const toolsByCategory: ToolCategory[] = [
103104
listConverter,
104105
tomlToJson,
105106
tomlToYaml,
107+
markdownToHtml,
106108
],
107109
},
108110
{

src/tools/markdown-to-html/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Markdown } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Markdown to html',
6+
path: '/markdown-to-html',
7+
description: '',
8+
keywords: ['markdown', 'html', 'converter'],
9+
component: () => import('./markdown-to-html.vue'),
10+
icon: Markdown,
11+
createdAt: new Date('2024-02-25'),
12+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script setup lang="ts">
2+
import markdownit from 'markdown-it';
3+
import TextareaCopyable from '@/components/TextareaCopyable.vue';
4+
5+
const inputMarkdown = ref('');
6+
const outputHtml = computed(() => {
7+
const md = markdownit();
8+
return md.render(inputMarkdown.value);
9+
});
10+
</script>
11+
12+
<template>
13+
<div>
14+
<c-input-text
15+
v-model:value="inputMarkdown"
16+
multiline raw-text
17+
placeholder="Your Markdown content..."
18+
rows="8"
19+
autofocus
20+
label="Your Markdown to convert:"
21+
/>
22+
23+
<n-divider />
24+
25+
<n-form-item label="Output HTML:">
26+
<TextareaCopyable :value="outputHtml" :word-wrap="true" language="html" />
27+
</n-form-item>
28+
</div>
29+
</template>

0 commit comments

Comments
 (0)