Skip to content

Commit 9ebf983

Browse files
committed
Merge branch 'feat/qr-decoder' of https://github.com/sharevb/it-tools into feat/qr-decoder
2 parents d30344b + a3a624c commit 9ebf983

File tree

7 files changed

+115
-10
lines changed

7 files changed

+115
-10
lines changed

components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ declare module '@vue/runtime-core' {
121121
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
122122
MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default']
123123
MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default']
124+
MarkdownToHtml: typeof import('./src/tools/markdown-to-html/markdown-to-html.vue')['default']
124125
MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default']
125126
MenuBar: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar.vue')['default']
126127
MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default']
@@ -129,6 +130,7 @@ declare module '@vue/runtime-core' {
129130
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
130131
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
131132
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
133+
NButton: typeof import('naive-ui')['NButton']
132134
NCode: typeof import('naive-ui')['NCode']
133135
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
134136
NColorPicker: typeof import('naive-ui')['NColorPicker']

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
"@types/figlet": "^1.5.8",
4546
"@vicons/material": "^0.12.0",
4647
"@vicons/tabler": "^0.12.0",
@@ -71,6 +72,7 @@
7172
"jwt-decode": "^3.1.2",
7273
"libphonenumber-js": "^1.10.28",
7374
"lodash": "^4.17.21",
75+
"markdown-it": "^14.0.0",
7476
"marked": "^10.0.0",
7577
"mathjs": "^11.9.1",
7678
"mime-types": "^2.1.35",

pnpm-lock.yaml

Lines changed: 51 additions & 10 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
@@ -10,6 +10,7 @@ import { tool as safelinkDecoder } from './safelink-decoder';
1010
import { tool as xmlToJson } from './xml-to-json';
1111
import { tool as jsonToXml } from './json-to-xml';
1212
import { tool as qrCodeDecoder } from './qr-code-decoder';
13+
import { tool as markdownToHtml } from './markdown-to-html';
1314
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
1415
import { tool as numeronymGenerator } from './numeronym-generator';
1516
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -113,6 +114,7 @@ export const toolsByCategory: ToolCategory[] = [
113114
tomlToYaml,
114115
xmlToJson,
115116
jsonToXml,
117+
markdownToHtml,
116118
],
117119
},
118120
{

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: 'Convert Markdown to Html and allow to print (as PDF)',
8+
keywords: ['markdown', 'html', 'converter', 'pdf'],
9+
component: () => import('./markdown-to-html.vue'),
10+
icon: Markdown,
11+
createdAt: new Date('2024-08-25'),
12+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
11+
function printHtml() {
12+
const w = window.open();
13+
if (w === null) {
14+
return;
15+
}
16+
w.document.body.innerHTML = outputHtml.value;
17+
w.print();
18+
}
19+
</script>
20+
21+
<template>
22+
<div>
23+
<c-input-text
24+
v-model:value="inputMarkdown"
25+
multiline raw-text
26+
placeholder="Your Markdown content..."
27+
rows="8"
28+
autofocus
29+
label="Your Markdown to convert:"
30+
/>
31+
32+
<n-divider />
33+
34+
<n-form-item label="Output HTML:">
35+
<TextareaCopyable :value="outputHtml" :word-wrap="true" language="html" />
36+
</n-form-item>
37+
38+
<div flex justify-center>
39+
<n-button @click="printHtml">
40+
Print as PDF
41+
</n-button>
42+
</div>
43+
</div>
44+
</template>

0 commit comments

Comments
 (0)