mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-23 14:21:04 +03:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23256695c3 | ||
|
|
69e660bf04 | ||
|
|
f5c4ab19bc | ||
|
|
67094980c9 | ||
|
|
87984e2081 | ||
|
|
318fb6efb9 | ||
|
|
f1a5489e21 | ||
|
|
e1b4f9aafe | ||
|
|
76a19d218d |
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB |
@@ -1,4 +1,8 @@
|
||||

|
||||
<picture>
|
||||
<source srcset="./.github/logo-dark.png" media="(prefers-color-scheme: light)">
|
||||
<source srcset="./.github/logo-white.png" media="(prefers-color-scheme: dark)">
|
||||
<img src="./.github/logo-dark.png" alt="logo">
|
||||
</picture>
|
||||
|
||||
Useful tools for developer and people working in IT. [Have a look !](https://it-tools.tech).
|
||||
|
||||
|
||||
Vendored
+13
-10
@@ -72,6 +72,7 @@ declare module '@vue/runtime-core' {
|
||||
DockerRunToDockerComposeConverter: typeof import('./src/tools/docker-run-to-docker-compose-converter/docker-run-to-docker-compose-converter.vue')['default']
|
||||
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
|
||||
Editor: typeof import('./src/tools/html-wysiwyg-editor/editor/editor.vue')['default']
|
||||
EmailNormalizer: typeof import('./src/tools/email-normalizer/email-normalizer.vue')['default']
|
||||
EmojiCard: typeof import('./src/tools/emoji-picker/emoji-card.vue')['default']
|
||||
EmojiGrid: typeof import('./src/tools/emoji-picker/emoji-grid.vue')['default']
|
||||
EmojiPicker: typeof import('./src/tools/emoji-picker/emoji-picker.vue')['default']
|
||||
@@ -110,6 +111,7 @@ declare module '@vue/runtime-core' {
|
||||
JsonMinify: typeof import('./src/tools/json-minify/json-minify.vue')['default']
|
||||
JsonToCsv: typeof import('./src/tools/json-to-csv/json-to-csv.vue')['default']
|
||||
JsonToToml: typeof import('./src/tools/json-to-toml/json-to-toml.vue')['default']
|
||||
JsonToXml: typeof import('./src/tools/json-to-xml/json-to-xml.vue')['default']
|
||||
JsonToYaml: typeof import('./src/tools/json-to-yaml-converter/json-to-yaml.vue')['default']
|
||||
JsonViewer: typeof import('./src/tools/json-viewer/json-viewer.vue')['default']
|
||||
JwtParser: typeof import('./src/tools/jwt-parser/jwt-parser.vue')['default']
|
||||
@@ -119,6 +121,7 @@ declare module '@vue/runtime-core' {
|
||||
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
|
||||
MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default']
|
||||
MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default']
|
||||
MarkdownToHtml: typeof import('./src/tools/markdown-to-html/markdown-to-html.vue')['default']
|
||||
MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default']
|
||||
MenuBar: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar.vue')['default']
|
||||
MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default']
|
||||
@@ -127,26 +130,21 @@ declare module '@vue/runtime-core' {
|
||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NDivider: typeof import('naive-ui')['NDivider']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NGi: typeof import('naive-ui')['NGi']
|
||||
NGrid: typeof import('naive-ui')['NGrid']
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
NH3: typeof import('naive-ui')['NH3']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
||||
NLabel: typeof import('naive-ui')['NLabel']
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSlider: typeof import('naive-ui')['NSlider']
|
||||
NSpin: typeof import('naive-ui')['NSpin']
|
||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||
NRadio: typeof import('naive-ui')['NRadio']
|
||||
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NTable: typeof import('naive-ui')['NTable']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
||||
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||
@@ -156,6 +154,9 @@ declare module '@vue/runtime-core' {
|
||||
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
|
||||
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
||||
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
||||
RegexMemo: typeof import('./src/tools/regex-memo/regex-memo.vue')['default']
|
||||
'RegexMemo.content': typeof import('./src/tools/regex-memo/regex-memo.content.md')['default']
|
||||
RegexTester: typeof import('./src/tools/regex-tester/regex-tester.vue')['default']
|
||||
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
|
||||
RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
@@ -165,6 +166,7 @@ declare module '@vue/runtime-core' {
|
||||
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
|
||||
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
|
||||
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
|
||||
StacktracePrettier: typeof import('./src/tools/stacktrace-prettier/stacktrace-prettier.vue')['default']
|
||||
StringObfuscator: typeof import('./src/tools/string-obfuscator/string-obfuscator.vue')['default']
|
||||
SvgPlaceholderGenerator: typeof import('./src/tools/svg-placeholder-generator/svg-placeholder-generator.vue')['default']
|
||||
TemperatureConverter: typeof import('./src/tools/temperature-converter/temperature-converter.vue')['default']
|
||||
@@ -188,6 +190,7 @@ declare module '@vue/runtime-core' {
|
||||
UuidGenerator: typeof import('./src/tools/uuid-generator/uuid-generator.vue')['default']
|
||||
WifiQrCodeGenerator: typeof import('./src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue')['default']
|
||||
XmlFormatter: typeof import('./src/tools/xml-formatter/xml-formatter.vue')['default']
|
||||
XmlToJson: typeof import('./src/tools/xml-to-json/xml-to-json.vue')['default']
|
||||
YamlToJson: typeof import('./src/tools/yaml-to-json-converter/yaml-to-json.vue')['default']
|
||||
YamlToToml: typeof import('./src/tools/yaml-to-toml/yaml-to-toml.vue')['default']
|
||||
YamlViewer: typeof import('./src/tools/yaml-viewer/yaml-viewer.vue')['default']
|
||||
|
||||
+12
-2
@@ -37,11 +37,13 @@
|
||||
"dependencies": {
|
||||
"@it-tools/bip39": "^0.0.4",
|
||||
"@it-tools/oggen": "^1.3.0",
|
||||
"@regexper/render": "^1.0.0",
|
||||
"@sindresorhus/slugify": "^2.2.1",
|
||||
"@tiptap/pm": "2.1.6",
|
||||
"@tiptap/starter-kit": "2.1.6",
|
||||
"@tiptap/vue-3": "2.0.3",
|
||||
"@types/figlet": "^1.5.8",
|
||||
"@types/markdown-it": "^13.0.7",
|
||||
"@vicons/material": "^0.12.0",
|
||||
"@vicons/tabler": "^0.12.0",
|
||||
"@vueuse/core": "^10.3.0",
|
||||
@@ -49,7 +51,6 @@
|
||||
"@vueuse/router": "^10.0.0",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"change-case": "^4.1.2",
|
||||
"chinesegen": "^0.3.3",
|
||||
"colord": "^2.9.3",
|
||||
"composerize-ts": "^0.6.2",
|
||||
"country-code-lookup": "^0.1.0",
|
||||
@@ -57,7 +58,9 @@
|
||||
"cronstrue": "^2.26.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"date-fns": "^2.29.3",
|
||||
"dom-to-image-more": "^3.4.5",
|
||||
"dompurify": "^3.0.6",
|
||||
"email-normalizer": "^1.0.0",
|
||||
"emojilib": "^3.0.10",
|
||||
"figlet": "^1.7.0",
|
||||
"figue": "^1.2.0",
|
||||
@@ -65,24 +68,29 @@
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
"javastack.js": "^1.0.2",
|
||||
"js-base64": "^3.7.6",
|
||||
"json5": "^2.2.3",
|
||||
"jsstack.js": "^2.0.0",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"libphonenumber-js": "^1.10.28",
|
||||
"lodash": "^4.17.21",
|
||||
"lorem-ipsum-japanese": "^1.0.1",
|
||||
"markdown-it": "^14.0.0",
|
||||
"marked": "^10.0.0",
|
||||
"mathjs": "^11.9.1",
|
||||
"mime-types": "^2.1.35",
|
||||
"monaco-editor": "^0.43.0",
|
||||
"naive-ui": "^2.35.0",
|
||||
"netmask": "^2.0.2",
|
||||
"netstack.js": "^2.0.0",
|
||||
"node-forge": "^1.3.1",
|
||||
"oui-data": "^1.0.10",
|
||||
"pdf-signature-reader": "^1.4.2",
|
||||
"pinia": "^2.0.34",
|
||||
"plausible-tracker": "^0.3.8",
|
||||
"pythonstack.js": "^1.0.2",
|
||||
"qrcode": "^1.5.1",
|
||||
"randexp": "^0.5.3",
|
||||
"sql-formatter": "^13.0.0",
|
||||
"ua-parser-js": "^1.0.35",
|
||||
"ulid": "^2.3.0",
|
||||
@@ -92,8 +100,10 @@
|
||||
"vue": "^3.3.4",
|
||||
"vue-i18n": "^9.9.1",
|
||||
"vue-router": "^4.1.6",
|
||||
"vue-shadow-dom": "^4.2.0",
|
||||
"vue-tsc": "^1.8.1",
|
||||
"xml-formatter": "^3.3.2",
|
||||
"xml-js": "^1.6.11",
|
||||
"yaml": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Generated
+785
-66
File diff suppressed because it is too large.
Load diff
@@ -7,6 +7,7 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
|
||||
import xmlHljs from 'highlight.js/lib/languages/xml';
|
||||
import yamlHljs from 'highlight.js/lib/languages/yaml';
|
||||
import iniHljs from 'highlight.js/lib/languages/ini';
|
||||
import markdownHljs from 'highlight.js/lib/languages/markdown';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const props = withDefaults(
|
||||
@@ -30,6 +31,7 @@ hljs.registerLanguage('html', xmlHljs);
|
||||
hljs.registerLanguage('xml', xmlHljs);
|
||||
hljs.registerLanguage('yaml', yamlHljs);
|
||||
hljs.registerLanguage('toml', iniHljs);
|
||||
hljs.registerLanguage('markdown', markdownHljs);
|
||||
|
||||
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
|
||||
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
function useDebouncedRef<T>(initialValue: T, delay: number, immediate: boolean = false) {
|
||||
const state = ref(initialValue);
|
||||
const debouncedRef = customRef((track, trigger) => ({
|
||||
get() {
|
||||
track();
|
||||
return state.value;
|
||||
},
|
||||
set: _.debounce(
|
||||
(value) => {
|
||||
state.value = value;
|
||||
trigger();
|
||||
},
|
||||
delay,
|
||||
{ leading: immediate },
|
||||
),
|
||||
}));
|
||||
return debouncedRef;
|
||||
}
|
||||
export default useDebouncedRef;
|
||||
@@ -3,9 +3,11 @@ import _ from 'lodash';
|
||||
import { type Ref, reactive, watch } from 'vue';
|
||||
|
||||
type ValidatorReturnType = unknown;
|
||||
type GetErrorMessageReturnType = string;
|
||||
|
||||
export interface UseValidationRule<T> {
|
||||
validator: (value: T) => ValidatorReturnType
|
||||
getErrorMessage?: (value: T) => GetErrorMessageReturnType
|
||||
message: string
|
||||
}
|
||||
|
||||
@@ -24,6 +26,15 @@ export function isFalsyOrHasThrown(cb: () => ValidatorReturnType): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function getErrorMessageOrThrown(cb: () => GetErrorMessageReturnType): string {
|
||||
try {
|
||||
return cb() || '';
|
||||
}
|
||||
catch (e: any) {
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
export interface ValidationAttrs {
|
||||
feedback: string
|
||||
validationStatus: string | undefined
|
||||
@@ -61,7 +72,13 @@ export function useValidation<T>({
|
||||
|
||||
for (const rule of get(rules)) {
|
||||
if (isFalsyOrHasThrown(() => rule.validator(source.value))) {
|
||||
state.message = rule.message;
|
||||
if (rule.getErrorMessage) {
|
||||
const getErrorMessage = rule.getErrorMessage;
|
||||
state.message = rule.message.replace('{0}', getErrorMessageOrThrown(() => getErrorMessage(source.value)));
|
||||
}
|
||||
else {
|
||||
state.message = rule.message;
|
||||
}
|
||||
state.status = 'error';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createPinia } from 'pinia';
|
||||
import { createHead } from '@vueuse/head';
|
||||
|
||||
import { registerSW } from 'virtual:pwa-register';
|
||||
import shadow from 'vue-shadow-dom';
|
||||
import { plausible } from './plugins/plausible.plugin';
|
||||
|
||||
import 'virtual:uno.css';
|
||||
@@ -23,5 +24,6 @@ app.use(i18nPlugin);
|
||||
app.use(router);
|
||||
app.use(naive);
|
||||
app.use(plausible);
|
||||
app.use(shadow);
|
||||
|
||||
app.mount('#app');
|
||||
@@ -0,0 +1,65 @@
|
||||
<script setup lang="ts">
|
||||
import { normalizeEmail } from 'email-normalizer';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const emails = ref('');
|
||||
const normalizedEmails = computed(() => {
|
||||
if (!emails.value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return emails.value
|
||||
.split('\n')
|
||||
.map((email) => {
|
||||
return withDefaultOnError(() => normalizeEmail({ email }), `Unable to parse email: ${email}`);
|
||||
})
|
||||
.join('\n');
|
||||
});
|
||||
|
||||
const { copy } = useCopy({ source: normalizedEmails, text: 'Normalized emails copied to the clipboard', createToast: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="mb-2">
|
||||
Raw emails to normalize:
|
||||
</div>
|
||||
<c-input-text
|
||||
v-model:value="emails"
|
||||
placeholder="Put your emails here (one per line)..."
|
||||
rows="3"
|
||||
multiline
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
autofocus
|
||||
monospace
|
||||
/>
|
||||
|
||||
<div class="mb-2 mt-4">
|
||||
Normalized emails:
|
||||
</div>
|
||||
<c-input-text
|
||||
:value="normalizedEmails"
|
||||
placeholder="Normalized emails will appear here..."
|
||||
rows="3"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
multiline
|
||||
readonly
|
||||
monospace
|
||||
/>
|
||||
<div class="mt-4 flex justify-center gap-2">
|
||||
<c-button @click="emails = ''">
|
||||
Clear emails
|
||||
</c-button>
|
||||
<c-button :disabled="!normalizedEmails" @click="copy()">
|
||||
Copy normalized emails
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Mail } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Email normalizer',
|
||||
path: '/email-normalizer',
|
||||
description: 'Normalize email addresses to a standard format for easier comparison. Useful for deduplication and data cleaning.',
|
||||
keywords: ['email', 'normalizer'],
|
||||
component: () => import('./email-normalizer.vue'),
|
||||
icon: Mail,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -4,6 +4,7 @@ import emojiKeywords from 'emojilib';
|
||||
import _ from 'lodash';
|
||||
import type { EmojiInfo } from './emoji.types';
|
||||
import { useFuzzySearch } from '@/composable/fuzzySearch';
|
||||
import useDebouncedRef from '@/composable/debouncedref';
|
||||
|
||||
const escapeUnicode = ({ emoji }: { emoji: string }) => emoji.split('').map(unit => `\\u${unit.charCodeAt(0).toString(16).padStart(4, '0')}`).join('');
|
||||
const getEmojiCodePoints = ({ emoji }: { emoji: string }) => emoji.codePointAt(0) ? `0x${emoji.codePointAt(0)?.toString(16)}` : undefined;
|
||||
@@ -23,7 +24,7 @@ const emojisGroups: { emojiInfos: EmojiInfo[]; group: string }[] = _
|
||||
.map((emojiInfos, group) => ({ group, emojiInfos }))
|
||||
.value();
|
||||
|
||||
const searchQuery = ref('');
|
||||
const searchQuery = useDebouncedRef('', 500);
|
||||
|
||||
const { searchResult } = useFuzzySearch({
|
||||
search: searchQuery,
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as emailNormalizer } from './email-normalizer';
|
||||
import { tool as stacktracePrettier } from './stacktrace-prettier';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
import { tool as textToUnicode } from './text-to-unicode';
|
||||
import { tool as safelinkDecoder } from './safelink-decoder';
|
||||
import { tool as xmlToJson } from './xml-to-json';
|
||||
import { tool as jsonToXml } from './json-to-xml';
|
||||
import { tool as regexTester } from './regex-tester';
|
||||
import { tool as regexMemo } from './regex-memo';
|
||||
import { tool as markdownToHtml } from './markdown-to-html';
|
||||
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
|
||||
import { tool as numeronymGenerator } from './numeronym-generator';
|
||||
import { tool as macAddressGenerator } from './mac-address-generator';
|
||||
@@ -107,6 +114,9 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
listConverter,
|
||||
tomlToJson,
|
||||
tomlToYaml,
|
||||
xmlToJson,
|
||||
jsonToXml,
|
||||
markdownToHtml,
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -148,6 +158,10 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
dockerRunToDockerComposeConverter,
|
||||
xmlFormatter,
|
||||
yamlViewer,
|
||||
emailNormalizer,
|
||||
regexTester,
|
||||
regexMemo,
|
||||
stacktracePrettier,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Braces } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'JSON to XML',
|
||||
path: '/json-to-xml',
|
||||
description: 'Convert JSON to XML',
|
||||
keywords: ['json', 'xml'],
|
||||
component: () => import('./json-to-xml.vue'),
|
||||
icon: Braces,
|
||||
createdAt: new Date('2024-08-09'),
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import convert from 'xml-js';
|
||||
import JSON5 from 'json5';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
|
||||
const defaultValue = '{"a":{"_attributes":{"x":"1.234","y":"It\'s"}}}';
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => {
|
||||
return convert.js2xml(JSON5.parse(value), { compact: true });
|
||||
}, '');
|
||||
}
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: (v: string) => v === '' || JSON5.parse(v),
|
||||
message: 'Provided JSON is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your JSON content"
|
||||
:input-default="defaultValue"
|
||||
input-placeholder="Paste your JSON content here..."
|
||||
output-label="Converted XML"
|
||||
output-language="xml"
|
||||
:transformer="transformer"
|
||||
:input-validation-rules="rules"
|
||||
/>
|
||||
</template>
|
||||
@@ -1,7 +0,0 @@
|
||||
declare module 'chinesegen' {
|
||||
export default function lorem(config: {
|
||||
count: number,
|
||||
}): {
|
||||
text: string
|
||||
};
|
||||
}
|
||||
@@ -1,39 +1,185 @@
|
||||
import _ from 'lodash';
|
||||
import loremIpsumJapanese from 'lorem-ipsum-japanese';
|
||||
import chinesegen from 'chinesegen';
|
||||
import languageLorems from './lorem-ipsum.i18n.json';
|
||||
import { randFromArray } from '@/utils/random';
|
||||
|
||||
const vocabulary = [
|
||||
'a',
|
||||
'ac',
|
||||
'accumsan',
|
||||
'ad',
|
||||
'adipiscing',
|
||||
'aenean',
|
||||
'aliquam',
|
||||
'aliquet',
|
||||
'amet',
|
||||
'ante',
|
||||
'aptent',
|
||||
'arcu',
|
||||
'at',
|
||||
'auctor',
|
||||
'bibendum',
|
||||
'blandit',
|
||||
'class',
|
||||
'commodo',
|
||||
'condimentum',
|
||||
'congue',
|
||||
'consectetur',
|
||||
'consequat',
|
||||
'conubia',
|
||||
'convallis',
|
||||
'cras',
|
||||
'cubilia',
|
||||
'cum',
|
||||
'curabitur',
|
||||
'curae',
|
||||
'dapibus',
|
||||
'diam',
|
||||
'dictum',
|
||||
'dictumst',
|
||||
'dignissim',
|
||||
'dolor',
|
||||
'donec',
|
||||
'dui',
|
||||
'duis',
|
||||
'egestas',
|
||||
'eget',
|
||||
'eleifend',
|
||||
'elementum',
|
||||
'elit',
|
||||
'enim',
|
||||
'erat',
|
||||
'eros',
|
||||
'est',
|
||||
'et',
|
||||
'etiam',
|
||||
'eu',
|
||||
'euismod',
|
||||
'facilisi',
|
||||
'faucibus',
|
||||
'felis',
|
||||
'fermentum',
|
||||
'feugiat',
|
||||
'fringilla',
|
||||
'fusce',
|
||||
'gravida',
|
||||
'habitant',
|
||||
'habitasse',
|
||||
'hac',
|
||||
'hendrerit',
|
||||
'himenaeos',
|
||||
'iaculis',
|
||||
'id',
|
||||
'imperdiet',
|
||||
'in',
|
||||
'inceptos',
|
||||
'integer',
|
||||
'interdum',
|
||||
'ipsum',
|
||||
'justo',
|
||||
'lacinia',
|
||||
'lacus',
|
||||
'laoreet',
|
||||
'lectus',
|
||||
'leo',
|
||||
'ligula',
|
||||
'litora',
|
||||
'lobortis',
|
||||
'lorem',
|
||||
'luctus',
|
||||
'maecenas',
|
||||
'magna',
|
||||
'magnis',
|
||||
'malesuada',
|
||||
'massa',
|
||||
'mattis',
|
||||
'mauris',
|
||||
'metus',
|
||||
'mi',
|
||||
'molestie',
|
||||
'mollis',
|
||||
'montes',
|
||||
'morbi',
|
||||
'mus',
|
||||
'nam',
|
||||
'nascetur',
|
||||
'natoque',
|
||||
'nec',
|
||||
'neque',
|
||||
'netus',
|
||||
'nisi',
|
||||
'nisl',
|
||||
'non',
|
||||
'nostra',
|
||||
'nulla',
|
||||
'nullam',
|
||||
'nunc',
|
||||
'odio',
|
||||
'orci',
|
||||
'ornare',
|
||||
'parturient',
|
||||
'pellentesque',
|
||||
'penatibus',
|
||||
'per',
|
||||
'pharetra',
|
||||
'phasellus',
|
||||
'placerat',
|
||||
'platea',
|
||||
'porta',
|
||||
'porttitor',
|
||||
'posuere',
|
||||
'potenti',
|
||||
'praesent',
|
||||
'pretium',
|
||||
'primis',
|
||||
'proin',
|
||||
'pulvinar',
|
||||
'purus',
|
||||
'quam',
|
||||
'quis',
|
||||
'quisque',
|
||||
'rhoncus',
|
||||
'ridiculus',
|
||||
'risus',
|
||||
'rutrum',
|
||||
'sagittis',
|
||||
'sapien',
|
||||
'scelerisque',
|
||||
'sed',
|
||||
'sem',
|
||||
'semper',
|
||||
'senectus',
|
||||
'sit',
|
||||
'sociis',
|
||||
'sociosqu',
|
||||
'sodales',
|
||||
'sollicitudin',
|
||||
'suscipit',
|
||||
'suspendisse',
|
||||
'taciti',
|
||||
'tellus',
|
||||
'tempor',
|
||||
'tempus',
|
||||
'tincidunt',
|
||||
'torquent',
|
||||
'tortor',
|
||||
'turpis',
|
||||
'ullamcorper',
|
||||
'ultrices',
|
||||
'ultricies',
|
||||
'urna',
|
||||
'varius',
|
||||
'vehicula',
|
||||
'vel',
|
||||
'velit',
|
||||
'venenatis',
|
||||
'vestibulum',
|
||||
'vitae',
|
||||
'vivamus',
|
||||
'viverra',
|
||||
'volutpat',
|
||||
'vulputate',
|
||||
];
|
||||
const firstSentence = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
|
||||
|
||||
export function getSupportedLanguages() {
|
||||
return _.union(
|
||||
_.flatten(_.chain(languageLorems).map(l => l.languages).value()),
|
||||
['Japanese', 'Chinese'])
|
||||
.sort();
|
||||
}
|
||||
|
||||
function generateSentence(language: string, length: number) {
|
||||
if (language === 'Japanese') {
|
||||
return loremIpsumJapanese({
|
||||
count: length,
|
||||
units: 'words',
|
||||
});
|
||||
}
|
||||
if (language === 'Chinese') {
|
||||
return chinesegen({ count: length }).text;
|
||||
}
|
||||
|
||||
if (language === 'Emoticon') {
|
||||
const loremIcons = _.find(languageLorems, ({ languages }) => languages.includes(language))?.loremIpsum || '';
|
||||
const iconsChars = [...loremIcons];
|
||||
return Array.from({ length })
|
||||
.map(() => randFromArray(iconsChars))
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
const vocabulary = _.find(languageLorems, ({ languages }) => languages.includes(language))?.loremIpsum?.split(' ') || [];
|
||||
|
||||
function generateSentence(length: number) {
|
||||
const sentence = Array.from({ length })
|
||||
.map(() => randFromArray(vocabulary))
|
||||
.join(' ');
|
||||
@@ -47,17 +193,15 @@ export function generateLoremIpsum({
|
||||
wordCount = 10,
|
||||
startWithLoremIpsum = true,
|
||||
asHTML = false,
|
||||
language = 'English',
|
||||
}: {
|
||||
paragraphCount?: number
|
||||
sentencePerParagraph?: number
|
||||
wordCount?: number
|
||||
startWithLoremIpsum?: boolean
|
||||
asHTML?: boolean
|
||||
language?: string
|
||||
}) {
|
||||
const paragraphs = Array.from({ length: paragraphCount }).map(() =>
|
||||
Array.from({ length: sentencePerParagraph }).map(() => generateSentence(language, wordCount)),
|
||||
Array.from({ length: sentencePerParagraph }).map(() => generateSentence(wordCount)),
|
||||
);
|
||||
|
||||
if (startWithLoremIpsum) {
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { generateLoremIpsum, getSupportedLanguages } from './lorem-ipsum-generator.service';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
import { generateLoremIpsum } from './lorem-ipsum-generator.service';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { randIntFromInterval } from '@/utils/random';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
|
||||
const paragraphs = useStorage('lorem:paragraphs', 1);
|
||||
const sentences = useStorage('lorem:sentences', [3, 8]);
|
||||
const words = useStorage('lorem:words', [8, 15]);
|
||||
const paragraphs = ref(1);
|
||||
const sentences = ref([3, 8]);
|
||||
const words = ref([8, 15]);
|
||||
const startWithLoremIpsum = ref(true);
|
||||
const asHTML = ref(false);
|
||||
const language = useQueryParamOrStorage({ defaultValue: 'English', storageName: 'lorem:lang', name: 'lang' });
|
||||
|
||||
const supportedLanguages = getSupportedLanguages();
|
||||
const [loremIpsumText, refreshLoremIpsum] = computedRefreshable(() =>
|
||||
generateLoremIpsum({
|
||||
paragraphCount: paragraphs.value,
|
||||
@@ -20,21 +17,14 @@ const [loremIpsumText, refreshLoremIpsum] = computedRefreshable(() =>
|
||||
sentencePerParagraph: randIntFromInterval(sentences.value[0], sentences.value[1]),
|
||||
wordCount: randIntFromInterval(words.value[0], words.value[1]),
|
||||
startWithLoremIpsum: startWithLoremIpsum.value,
|
||||
language: language.value,
|
||||
}),
|
||||
);
|
||||
|
||||
const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to the clipboard' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-card>
|
||||
<c-select
|
||||
v-model:value="language"
|
||||
searchable
|
||||
label="Language:"
|
||||
:options="Object.values(supportedLanguages)"
|
||||
mb-2
|
||||
/>
|
||||
<n-form-item label="Paragraphs" :show-feedback="false" label-width="200" label-placement="left">
|
||||
<n-slider v-model:value="paragraphs" :step="1" :min="1" :max="20" />
|
||||
</n-form-item>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
declare module 'lorem-ipsum-japanese' {
|
||||
export default function lorem(config: {
|
||||
count: number,
|
||||
units: 'words' | 'sentences' | 'paragraphs',
|
||||
}): string;
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
[
|
||||
{
|
||||
"languages": [
|
||||
"English",
|
||||
"Latin"
|
||||
],
|
||||
"loremIpsum": "Lorem ipsum dolor sit amet, unum corrumpit ea mei, has latine instructior no, simul choro senserit at qui! In eam copiosae efficiendi, vis iuvaret nominati cu. In mel possit tincidunt! Has in vidisse convenire. Vis deleniti rationibus definiebas ea, autem partem vim id?"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Czech"
|
||||
],
|
||||
"loremIpsum": "Lorem ipsum dolor šit amét, šůmmo mundi eloquenťíam eum id? Malis aliquam vix cu, quodsi dólorum id vim, te mučiús cétero čompreheňsám sěd. Nó accumsán mentitum antiopam nam! Nóstro ornatus sčriptorem neč ex, ešt ťe štet ornatůs. Íllům aúďire iracundia siť aň, pri próbo copiósae ťempoříbús ex. Dúo cu ludúš nošter!"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Norwegian",
|
||||
"Danish"
|
||||
],
|
||||
"loremIpsum": "Lørem ipsum dolør sit amet, eæ hinc cibo feugåit nec. Mel ei mødo copiosae partiendo. Inermis fuisset perfecto duo ut. Sumo elabøraret quo et, usu tempor luptatum måndamus ei, læbore habemus åd per."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"French"
|
||||
],
|
||||
"loremIpsum": "Lorém ïpsum dolôr sït àmet, êî môdûs possîm eleçtram eum. Pérîculis intêllegebat at per, êâ nam êros âudiam, fabulas opôrtéat rèfërrëntûr mél éx. Të ius grâeco scribéntur, ëa adhuc posïdônium est? Côrporà volùptatum ad nam, mël fêrri lêgimùs êligendi în, nè his vidissé insolêns! Qùî màlîs tôllit periçulîs tè, quô eï summo çommune aççusàta?"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Hungarian"
|
||||
],
|
||||
"loremIpsum": "Lorém ipsum dolör sit amet, omnes nüllam tamqűam ád quo, sit ut brute iisqüe voluptatibus! An seá fastidíi delicata indoctum? Ius éi dictá platönem, seá cú odiö dolőr iüvaret? Eos út férri hómerő élőquentíám, quót prodesset te his. Id pri alií nöstér cónsequüntúr, íűvaret eripuit hendrerít vim íd, in möllís laoreet antiopam est."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Icelandic"
|
||||
],
|
||||
"loremIpsum": "Lorem ipsum dolör sít amet, cu officiis accómmodare vix. Agam menandri per an! Eí fugit clíÞæ ubiqúe sed. Congue nónúmes ius ei! Cum Þe ímpeÞus appellæntur."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Italian"
|
||||
],
|
||||
"loremIpsum": "Lórem ipsum dòlór sìt amét, dúo dòlòrès dèleniti deterrùissét ad. His sumo constituàm adversaríum ne, quí labòrès appellàntùr té, mei harum refòrmidans íd? Dùò et gràeco lucìliùs, qui ne álìi reprimiqúè? Erat àccusamus nèc cú, cum éi novúm reprimique. His póssim òblìque id, eu ést nisl fugit referrèntúr, salutandi ássentior mèì eu?"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Old English"
|
||||
],
|
||||
"loremIpsum": "Lorem ipsum dolor sīt æmēt, ād mei soleÞ ignoÞā putent, sāle ināni cū pri, ērǣnt corpora nēglegentur quī eu. Ēu ċūm sāƿċÞūs ārġumentūm eloquenÞiǣm. Usu ne assum libris! Purto proȝatūs scripÞōrem ius īn. Et mea nominavi fæcilisis, ludūs vīÞǣe eūm ad. Diċām discerē ei vēl. Vide prāeseƿt īd qūi?"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Polish"
|
||||
],
|
||||
"loremIpsum": "Lorem ipsum dolor sit amet, sea ut illud trąctątos, harum civibus ęa męi? Ut usu graecis nomińavi śalutatus. Impedit opórteat ćum et, laudem łabóre cu sit? Nec causaę diceret te, vim zril diśseńtiunt ćoncłudaturque te!"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Portuguese"
|
||||
],
|
||||
"loremIpsum": "Lõrém ipsúm dolôr sit amet, pro çongue libris deserunt in, ut débet putent máiéstãtis eós? Mei àt odio sáépê? Cu sít viderer deniqué, dícat tritani eu mel, láóreét nónumes definitiónes pri eá! Bõnorúm inimiçus vulputáte ut vis? Nisl volumus et mél, quod iudíco inçórruptê vis et."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Spanish"
|
||||
],
|
||||
"loremIpsum": "Lórem ipsum dolor sit amét, soñet iudicabit quaeréñdum no vis, pro eu modús admodúm suscipit, ea rebum equídem temporibús nám. Eu sed delicata temporibus, et élit illud vel, et mundi deleniti est. Té has accumsan vituperatoribus, vís nisl deseruisse ád. ¿Cúm elítr reprimiqué signiferumque ne, an habémus advérsarium ius, pri ádhuc exerci iñvenire id? Eum cu facilis recteque."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Swedish"
|
||||
],
|
||||
"loremIpsum": "Lorem ipsum dölor sit amet, ei duö alia wisi impetus, än ubique referrentur necessitatibus duo. Reque ömnes persius hæs an, æn vel vidisse denique! Sit sæepe recteque æt, nemore euripidis ex vix, inimicus consetetur per no? Nam id delenit persecuti, ad næm tota eleifend?"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Turkish"
|
||||
],
|
||||
"loremIpsum": "Lorem ıpşûm dolor sît amet, əa ullum voceňt façilisi ňəç. Duo fuğît übiquə quaeque ňe, in cum clita laudem vıtuperata. Scribentur complectıtur an sed, ıus mınim molestie iudîcabit ea? Pri eî ûnum posse meliuş, primis timeam eam at. Ut laudem librîs latinə ius, vım əx iîsqüe accûmsan pöşıdoňîum, id sed dicta vidissə convenıre. Vietnamese Lorem ipsưm dôlor sit ămet, quot recusăbo definitionem no usu, ornatus honestâtis id mel? Eă purtơ idque sit. Nam ưllum animâl minimum te, vel ei ancillăê expêtênda! Êt vis postea officiis iracunđia, sit dôctus ăpeiriăn principes nơ?"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Yugoslavian"
|
||||
],
|
||||
"loremIpsum": "Duo te đžico oblique, ex vel eligendži čonšequat. Đžicta urbanitas ex mea. An meis virtute euripiđžiš vis, ius elit voluptaria cu, ut quo quis dečore exerci. Ei per munere impedit ćontentiones, sonet labitur est eu. Đuis tation eirmođž quo in, ne unum nullam aliquip eum?"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Lëtzebuergesch"
|
||||
],
|
||||
"loremIpsum": "Dé d'Loft Säiten heemlech wär, zwé gutt fest fu? Dem ze d'Liewen schéinste, vu och drun schéinste. Ke méi Monn Noper, Räis gefällt prächteg fu méi, Lann Mier ugedon op déi? No Kaffi genuch hie, op geet Mecht derbei all, Gaas Engel wou op. Si hin Heck gréng schéinen, Monn Gart weisen rem wa. Wäit keen hirem vun mä, as Heck d'Liewen hie, am keen gebotzt vun?"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Russian"
|
||||
],
|
||||
"loremIpsum": "Лорем ипсум долор сит амет, нец не постеа медиоцритатем, модус абхорреант диссентиет при цу, ет идяуе убияуе пробатус при. Вис пауло репудиандае ад, еуисмод яуаерендум детерруиссет при еу? Денияуе дефинитионем яуо ин, оффициис торяуатос при еа, нам чоро ехплицари витуперата не. Миним алияуид пхилосопхиа сед те. Яуи алии вереар елояуентиам ат, ад вим яуодси оффициис. Но яуо алияуам."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Greek"
|
||||
],
|
||||
"loremIpsum": "Λορεμ ιπσθμ δολορ σιτ αμετ, τε jθστο πετεντιθμ ασσεντιορ σεδ, ηισ ιν ταντασ qθαεστιο cορρθμπιτ. Cθμ ιν δισcερε νολθισσε ποσιδονιθμ. Δολορεσ δελεcτθσ σενσιβθσ μει νε! Περ ετ μαγνα ιθδιcο θβιqθε, οδιο δοcενδι σαλθτατθσ θτ περ, ει προ ερρεμ vιταε οβλιqθε. Τε εστ σολθτα σαλθτανδι cονσθλατθ, αν προ ταλε ιντερεσσετ. Εσσε σολθτα εα vιμ."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Armenian"
|
||||
],
|
||||
"loremIpsum": "լոռեմ իպսում դոլոռ սիթ ամեթ, լոռեմ պլաթոնեմ հիս եթ? ին ուռբանիթաս եֆֆիծիանթուռ սիթ. քուեմ ոֆֆիծիիս ադ ծում. մել ան սիմուլ եռուդիթի դոծենդի, նե մել պուռթո ադիպիսծինգ, դուո եու եռանթ իուդիծո. սեդ նե բոնոռում պռոբաթուս վուլպութաթե, նո վոլումուս պլաթոնեմ ռեֆոռմիդանս վիխ! հաս եթ եսսենթ."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Georgian"
|
||||
],
|
||||
"loremIpsum": "ლორემ იფსუმ დოლორ სით ამეთ, ჰას ფერთინახ ადოლესცენს ად! მოვეთ დოლორუმ ინვენირე ფრო ათ. ათ ალია ცონთენთიონეს ნამ, ან ჰის ყუოთ ირაცუნდია? ყუოთ სუმმო ერრორიბუს ნამ უთ."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Hindi"
|
||||
],
|
||||
"loremIpsum": "७हल समजते भोगोलिक ढांचामात्रुभाषा! अथवा चिदंश अधिकार बिन्दुओमे सादगि सभिसमज अमितकुमार उपयोगकर्ता संभव. बिन्दुओ उपयोगकर्ता बहुत प्रति. कर्य किएलोग बिन्दुओ हिंदी. उपलब्ध अंग्रेजी होगा लक्षण प्रदान निर्देश बेंगलूर सादगि पडता? खरिदने संपुर्ण शीघ्र वर्ष अतित संपुर्ण यन्त्रालय प्रोत्साहित पहोच। किया प्राण एसलिये प्राप्त!"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Korean"
|
||||
],
|
||||
"loremIpsum": "가부동수인 때에는 부결된 것으로 본다. 자유민주적 기본질서에 입각한 평화적 통일 정책을 수립하고 이를 추진한다. 다만. 국민경제의 발전을 위한 중요정책의 수립에 관하여 대통령의 자문에 응하기 위하여 국민경제자문회의를 둘 수 있다. 방황하였으며, 곳이 가지에 열락의 낙원을 봄바람을 물방아 역사를 힘있다. 듣기만 불러 공자는 것이다, 미인을 구하지 것은 못할 스며들어 위하여서, 곧 무엇을 보배를 있으며. 있으며. 할지니. 풀이 있으며."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Arabic"
|
||||
],
|
||||
"loremIpsum": "فقد مسرح سقوط بريطانيا-فرنسا بل. ثم وعلى شموليةً إيو. كلّ في الوراء الأثنان, عل أخذ الأولية الخارجية. جيما وكسبت التاريخ، قبل إذ, هذه تم السبب التحالف باستحداث, به، من عُقر بالفشل الإتحاد. مدينة بمباركة لمّ ٣٠, كلّ إستعمل الفرنسية ويكيبيديا لم, عن قام المشترك للسيطرة"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Hebrew"
|
||||
],
|
||||
"loremIpsum": "רבה אל ספורט מונחים שינויים. דת אחר החלל דפים אנתרופולוגיה. יידיש מאמרשיחהצפה ויש אם, של לוח ומהימנה האנציקלופדיה. אם ביולי קישורים תנך, לראות רוסית האטמוספירה תנך על, ארץ המלצת בהשחתה לחשבון מה. בה מדעי הבאים ואלקטרוניקה חפש, קלאסיים לימודים מלא אם, מחליטה אחרונים היסטוריה אל מתן."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"L33tspeak"
|
||||
],
|
||||
"loremIpsum": "534r(h r35ul7. 17 +h3, Ph13LD, 4u70m471(4lly 1n y0:. 1n 937 g0t0 3ng|335h,, t3H 1n70 1iNx Wh0 +o, pHor d1|23c73d 937 +o. 1T 250m (ra//1z h1gh-qu4|17y 0u7. 70 4rE h34d3r L0Ok1NG."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Morse code"
|
||||
],
|
||||
"loremIpsum": "·--- ·--· --··· -- -·- --- -··· ··-· --·· -· ·-- -·-· -··- ·· -- ··- ····· ··--··"
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Emoticon"
|
||||
],
|
||||
"loremIpsum": "👋🏻👋🏼👋🏽👋🏾👋🏿🤚🏻🤚🏼🤚🏽🤚🏾🤚🏿🖐🏻🖐🏼🖐🏽🖐🏾🖐🏿🖖🏻🖖🏼🖖🏽🖖🏾🖖🏿👌🏻👌🏼👌🏽👌🏾🤌🤌🏽🤌🏾🤌🏿🤏🏻🤏🏼🤏🏽🤏🏾🤏🏿🤞🏻🤞🏼🤞🏽🤞🏾🤞🏿🤟🏻🤟🏼🤟🏽🤟🏾🤟🏿🤘🏻🤘🏼🤘🏽🤘🏾🤘🏿🤙🏼🤙🤙🤙🏿👈🏻👈🏼👈🏽👈🏾👈🏿👉🏻👉🏼👉🏽👉🏾👉🏿👆🏻👆🏼👆🏽👆🏾👆🏿🖕🏻🖕🏼🖕🏽🖕🏾🖕🏿👇🏻👇🏼👇👇🏾👇👍🏻👍🏼👍🏽👍🏾👍🏿👎🏻👎🏼👎🏽👎🏾👎🏿👊🏻👊🏼👊🏽👊🏾👊🏿🤛🏻🤛🏼🤛🏽🤛🏾🤛🏿🤜🏻🤜🏼🤜🤜🏾🤜🏿👏👏🏼👏🏽👏🏾👏🏿🙌🏻🙌🏼🙌🏽🙌🏾🙌🏿👐🏻👐🏼👐🏽👐🏾👐🏿🤲🏻🤲🏼🤲🏽🤲🏾🤲🏿🙏🏻🙏🏼🙏🙏🏾🙏🏿💅🏻💅💅🏽💅🏾💅🏿🤳🏻🤳🏼🤳🏽🤳🏾🤳🏿💪🏻💪🏼💪🏽💪🏾💪🏿🦵🏻🦵🏼🦵🏽🦵🏾🦶🏼🦶🏽🦶🏾🦶👂🏻👂🏼👂🏽👂🏾👂🦻🏻🦻🏼🦻🏽🦻🏾🦻🏿👃🏻👃🏼👃🏽👃🏾👃🏿👶🏻👶🏼👶🏽👶🏾👶🏿🧒🏻🧒🏼🧒🏽🧒🏾🧒👦🏻👦🏼👦🏽👦🏾👦🏿👧👧🏼👧🏽👧🏾👧🏿🧑🏻🧑🏼🧑🏽🧑🏾🧑🏿👱🏻👱🏼👱🏽👱🏾👱🏿👨🏻👨🏼👨🏽👨🏾👨🧔🏻🧔🏼🧔🏽🧔🏾🧔🏿👩🏻👩👩🏽👩🏾👩🏿🧓🏻🧓🏼🧓🏽🧓🏾🧓🏿👴🏻👴🏼👴🏽👴🏾👴🏿👵🏻👵🏼👵🏽👵🏾👵🙍🏻🙍🏼🙍🏽🙍🏾🙍🏿🙎🏻🙎🏼🙎🙎🏾🙎🏿🙅🏻🙅🏼🙅🏽🙅🏾🙅🏿🙆🏻🙆🏼🙆🏽🙆🏾🙆🏿💁🏻💁🏼💁🏽💁🏾💁🙋🏻🙋🏼🙋🏽🙋🏾🙋🏿🧏🏻🧏🏼🧏🏽🧏🧏🏿🙇🏻🙇🏼🙇🏽🙇🏾🙇🏿🤦🏻🤦🏼🤦🏽🤦🏾🤦🏿🤷🏻🤷🏼🤷🏽🤷🏾🤷👮🏻👮🏼👮🏽👮🏾👮🏿🕵🏻🕵🏼🕵🏽🕵🏾🕵💂🏻💂🏼💂🏽💂🏾💂🏿🥷🏻🥷🏼🥷🏽🥷🏾🥷🏿👷🏻👷🏼👷🏽👷🏾👷🤴🏻🤴🏼🤴🏽🤴🏾🤴🏿👸🏻👸🏼👸🏽👸🏾👸🏿👳👳🏼👳🏽👳🏾👳🏿👲🏻👲🏼👲🏽👲🏾👲🏿🧕🏻🧕🏼🧕🏽🧕🏾🧕🤵🏻🤵🏼🤵🏽🤵🏾🤵🏿👰🏻👰🏼👰🏽👰🏾👰🏿🤰🏻🤰🤰🏽🤰🏾🤰🏿🤱🏻🤱🏼🤱🏽🤱🏾🤱🏿👼🏻👼🏼👼🏽👼🏾👼🎅🏻🎅🏼🎅🏽🎅🏾🎅🏿🤶🏻🤶🏼🤶🏽🤶🏾🤶🏿🦸🏻🦸🏼🦸🦸🏾🦸🏿🦹🏻🦹🏼🦹🏽🦹🏾🦹🏿🧙🏻🧙🏼🧙🏽🧙🏾🧙🧚🏻🧚🏼🧚🏽🧚🏾🧚🏿🧛🏻🧛🏼🧛🏽🧛🏾🧛🏿🧜🏻🧜🏼🧜🏽🧜🧜🏿🧝🏻🧝🏼🧝🏽🧝🏾🧝🏿💆🏻💆🏼💆🏽💆🏾💆💇🏻💇🏼💇🏽💇🏾💇🏿🚶🏻🚶🏼🚶🏽🚶🏾🚶🏿🧍🏻🧍🏼🧍🏽🧍🏾🧍🧎🏻🧎🏼🧎🏽🧎🏾🧎🏿🏃🏻🏃🏼🏃🏽🏃🏾🏃💃🏻💃🏼💃🏽💃🏾💃🏿🕺🏻🕺🏼🕺🏽🕺🏾🕺🏿🕴🏻🕴🏼🕴🏽🕴🏾🕴🏿🧖🧖🏼🧖🏽🧖🏾🧖🏿🧗🏻🧗🏼🧗🏽🧗🏾🧗🏿🏇🏻🏇🏼🏇🏽🏇🏾🏇🏿🏂🏻🏂🏼🏂🏽🏂🏾🏂🏿🏌🏻🏌🏼🏌🏽🏌🏾🏌🏿🏄🏻🏄🏼🏄🏽🏄🏾🏄🏿🚣🏻🚣🏼🚣🏽🚣🏾🚣🏿🏊🏻🏊🏼🏊🏽🏊🏾🏊🏿🏋🏻🏋🏼🏋🏽🏋🏾🏋🏿🚴🏻🚴🏼🚴🏽🚴🏾🚴🏿🚵🏻🚵🏼🚵🏽🚵🏾🚵🏿🤸🏻🤸🏼🤸🏾🤸🏿🤽🏻🤽🏼🤽🏽🤽🏾🤽🏿🤾🏻🤾🏼🤾🏽🤾🏾🤾🏿🤹🏻🤹🏼🤹🏽🤹🏾🤹🏿🧘🏻🧘🏼🧘🏽🧘🏾🧘🏿🛀🏻🛀🏼🛀🏽🛀🏾🛀🏿🛌🏻🛌🏼🛌🏽🛌🏾🛌🏿👭🏻👭🏼👭🏽👭🏾👭🏿👫🏻👫🏼👫🏽👫🏾👫🏿👬🏻👬🏼👬🏽👬🏾👬🏿💏🏻💏🏽💏🏾💏🏿💑🏼💑🏽💑🏾💑🏿#️⃣0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣✋🏻✋🏼✋🏽✋🏾✋🏿✌🏻✌🏼✌✌☝🏻☝🏼☝🏽✊🏻✊🏼✊🏽✊🏾✊🏿✍🏻✍🏼✍🏽✍🏾✍🏿⛹🏻⛹🏼⛹🏽⛹🏾⛹🏿😀😃😄😁😆😅🤣😂🙂🙃😉😊😇🥰😍🤩😘😗😚😙🥲😋😛😜🤪😝🤑🤗🤭🤫🤔🤐🤨😐😑😶😏😒🙄😬🤥😌😔😪🤤😴😷🤒🤕🤢🤮🤧🥵🥶🥴😵🤯🤠🥳🥸😎🤓🧐😕😟🙁😮😯😲😳🥺😦😧😨😰😥😢😭😱😖😣😞😓😩😫🥱😤😡😠🤬😈👿💀💩🤡👹👺👻👽👾🤖😺😸😹😻😼😽🙀😿Line truncated
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Esperanto"
|
||||
],
|
||||
"loremIpsum": "Tuj nu vic' reala, kombi kvanto kontraŭe ut hop, sat ro responde multekosta alternativa. Is devus eksterna antaŭelemento nun, sat peti plus alimaniere am, il minca makro ligfinaĵo muo. Da solstariva tutampleksa mia, faka gardi per do. Trudi prepoziciaĵo sed ol, e cia cento ferio kontraŭi."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Interlingua"
|
||||
],
|
||||
"loremIpsum": "Sed da russo initialmente principalmente, cadeva introductori duo in, via il contos tempore publicava. Infra traduction finalmente sed al, ha russo commun hereditage sed. Es regno libere international del, via tu sine summarios. Tu ultra vocabulario pro, prime westeuropee tu via. Maximo gymnasios pro da. Unidirectional immediatemente uso le."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Quenya"
|
||||
],
|
||||
"loremIpsum": "Óla caila estel at. Tólë engë arandur tin ep, us lauta amaurëa náhanemnam tur. Ya ainu cuilë nén, vëaner caimassë nir be. Hui oa turúva amaurëa hlonítë, wilwarin ambarenya nú úil. Sívë nurtalom hat nú, lëo telpë metta laira nó, venë andamunda tál má."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Slovio"
|
||||
],
|
||||
"loremIpsum": "Leto kuharju so kai. Takak probudijm vi moi. Bil oliv gladju celuvajt es, on mne imenim drugica politikju. Dva maluo svadit ja, iz moi rusju gvorijt lubovijm. Bil no tonkju prekrasju, li cxai razlicxju uzx. Sxkol vnimanie roditelis da vse. Imajsx dolaris ku din, perv idijte cxistju bi din."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Sona"
|
||||
],
|
||||
"loremIpsum": "On ino pekaba kayosama, bia je denda ikibani, udara pecin ade in. Cai visu purojen universita pe, sun ta cebi ugoba. Ne ipe udara giuma gadio. Co tonni adusinyo izo, mi sir zoro fuga amulio. Zu ika gase finyuri, udara mendi ni vin. Teka panni nefida on via, inri mendi sangenci sen ni, sun ne suko agama kenda. Zi ila veca lire kini, zina para ubeni cai ne."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Tokipona"
|
||||
],
|
||||
"loremIpsum": "a ijo kute pona waso, suwi mije sijelo wan ni, mun taso sina linja ko. ale jaki lawa en, ijo mi conj sike pimeja, seli pilin kepeken oko ni. li suno unpa lukin ike. conj lukin a oko, anu a olin sijelo. ike toki taso lawa ko. lipu wawa wan mu."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Volapük"
|
||||
],
|
||||
"loremIpsum": "Frutidol gitavan mutaragran pö tum. Dis nu plekols sümon, vom posä sasenanis us. Nemol-li palelifükons simulans tü cem, kälälolsöd posä zänodü at bod. Els di dotolsöv neodols yulo, kol jutedans laka lemiko of, ye yeb blunedolsöd edasevoy. Päsätükons vomes tum pö, prodi sepülön velna-li deg kü, dil it lecenolsöd leklära taläntis."
|
||||
},
|
||||
{
|
||||
"languages": [
|
||||
"Thai"
|
||||
],
|
||||
"loremIpsum": "แอปเปิล เชฟโปรเจคท์ ฟีด คอร์ป อ่วมแพนดาพะเรอเจ็ต ฮาโลวีนทับซ้อนรีเสิร์ช สเตชัน เอ็นทรานซ์คอรัปชั่นแคร็กเกอร์ สี่แยกล็อบบี้ซิมพันธกิจ แคปซูเอี๋ยสตรอว์เบอร์รี นิรันดร์สมิติเวชดาวน์ สป็อต แทงโก้วาริชศาสตร์ ออร์แกนิค เซ็นเตอร์โอเพ่นแฟรนไชส์ราเมน บร็อกโคลีแมคเคอเรลบูติค ตัวเองสต๊อก โค้ชคอนแทคอพาร์ทเมนต์ เหมยแครกเกอร์รีโมต แอพพริคอทออเดอร์หลวงตาคลิป อัตลักษณ์ฟรุตบ๊อบ วิดีโอแอโรบิค วาไรตี้เยอบีราแคมป์สถาปัตย์ บอมบ์ตุ๊กตุ๊กผลไม้พิซซ่าอัลมอนด์ ตุ๊กช็อค สไลด์ดยุค ทัวร์ เคลียร์มือถือลามะ เทวาธิราชแบล็กวีเจ แบรนด์แอ็คชั่น โกะ ล็อตฮ็อตวัคค์ ลอร์ดฟินิกซ์ยังไงฮวงจุ้ยฟินิกซ์ โอเลี้ยงคาปูชิโนโปรเจ็ค ความหมายปิกอัพมิวสิค คอมเมนท์ฟีดสมิติเวช รีไทร์ท็อปบู๊ท โมจิพิซซ่าซิง ลีกเพลซน็อก ลาเต้ แพ็ค ดีกรี สเปคดีพาร์ทเมนต์ แคร์ตื้บ หมวยรามเทพธัมโมคีตกวี สเตอริโอป๋อหลอจอหงวน พฤหัสรูบิคปูอัดริคเตอร์ พาร์ทเนอร์รีทัช มาร์ชไอติม ม้าหินอ่อน ฮีโร่ บาร์บี้ ทับซ้อนโมเดิร์นคาร์โก้สปอต ลิมูซีนมาร์เก็ตติ้ง ฮัมถูกต้องโปรดิวเซอร์แอดมิชชั่น พาสเจอร์ไรส์โบ้ยเกสต์เฮาส์ บร็อกโคลีนรีแพทย์ ความหมายว่ะสมาพันธ์ แหววเอสเพรสโซอพาร์ทเมนท์ มั้ยนิวส์ สต๊อคท็อปบู๊ท ไนน์เทวาระโงก แบคโฮช็อปชัตเตอร์ ตอกย้ำฮ็อตด็อกตัวตนอัลตราแซ็ก ปอดแหก คอนเซ็ปต์ม้งเวเฟอร์ ซูฮกสเก็ตช์ กีวีวิดีโอ ทัวริสต์ เซรามิก ม้าหินอ่อน แมกกาซีนฟรุตสปอตแชมปิยอง วีเจ สเก็ตช์แฟล็ตแพกเกจกุนซือ แดนเซอร์ไหร่ รันเวย์ปาสกาลโบ้ย ฟีเวอร์มาร์เก็ตคอนเทนเนอร์รัม ฟีเวอร์ เซฟตี้ดีกรี สไตรค์สามช่าดาวน์ โมเดิร์นเทค จิตพิสัย อัลมอนด์ ทิปวโรกาส นายแบบแอลมอนด์วอลล์ แทคติค โอยัวะดาวน์ใช้งานแทงกั๊ก สเตชันฟรุต ริกเตอร์คาราโอเกะ ปาสกาลอิกัวนา ฮัลโหล ไฮบริด พาสปอร์ต แจม ยนตรกรรม มอคค่าเซ็นทรัลซาร์ดีน จูเนียร์ต่อยอดฟอยล์ อัลมอนด์สะบึมวาไรตี้ เทคนิค ดูน่าสนใจขึ้นมากกว่าภาพนิ่ง"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Markdown } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Markdown to HTML',
|
||||
path: '/markdown-to-html',
|
||||
description: 'Convert Markdown to Html and allow to print (as PDF)',
|
||||
keywords: ['markdown', 'html', 'converter', 'pdf'],
|
||||
component: () => import('./markdown-to-html.vue'),
|
||||
icon: Markdown,
|
||||
createdAt: new Date('2024-08-25'),
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import markdownit from 'markdown-it';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
|
||||
const inputMarkdown = ref('');
|
||||
const outputHtml = computed(() => {
|
||||
const md = markdownit();
|
||||
return md.render(inputMarkdown.value);
|
||||
});
|
||||
|
||||
function printHtml() {
|
||||
const w = window.open();
|
||||
if (w === null) {
|
||||
return;
|
||||
}
|
||||
w.document.body.innerHTML = outputHtml.value;
|
||||
w.print();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="inputMarkdown"
|
||||
multiline raw-text
|
||||
placeholder="Your Markdown content..."
|
||||
rows="8"
|
||||
autofocus
|
||||
label="Your Markdown to convert:"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<n-form-item label="Output HTML:">
|
||||
<TextareaCopyable :value="outputHtml" :word-wrap="true" language="html" />
|
||||
</n-form-item>
|
||||
|
||||
<div flex justify-center>
|
||||
<n-button @click="printHtml">
|
||||
Print as PDF
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { BrandJavascript } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Regex cheatsheet',
|
||||
path: '/regex-memo',
|
||||
description: 'Javascript Regex/Regular Expression cheatsheet',
|
||||
keywords: ['regex', 'regular', 'expression', 'javascript', 'memo', 'cheatsheet'],
|
||||
component: () => import('./regex-memo.vue'),
|
||||
icon: BrandJavascript,
|
||||
createdAt: new Date('2024-09-20'),
|
||||
});
|
||||
@@ -0,0 +1,121 @@
|
||||
### Normal characters
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
`.` or `[^\n\r]` | any character *excluding* a newline or carriage return
|
||||
`[A-Za-z]` | alphabet
|
||||
`[a-z]` | lowercase alphabet
|
||||
`[A-Z]` | uppercase alphabet
|
||||
`\d` or `[0-9]` | digit
|
||||
`\D` or `[^0-9]` | non-digit
|
||||
`_` | underscore
|
||||
`\w` or `[A-Za-z0-9_]` | alphabet, digit or underscore
|
||||
`\W` or `[^A-Za-z0-9_]` | inverse of `\w`
|
||||
`\S` | inverse of `\s`
|
||||
|
||||
### Whitespace characters
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
` ` | space
|
||||
`\t` | tab
|
||||
`\n` | newline
|
||||
`\r` | carriage return
|
||||
`\s` | space, tab, newline or carriage return
|
||||
|
||||
### Character set
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
`[xyz]` | either `x`, `y` or `z`
|
||||
`[^xyz]` | neither `x`, `y` nor `z`
|
||||
`[1-3]` | either `1`, `2` or `3`
|
||||
`[^1-3]` | neither `1`, `2` nor `3`
|
||||
|
||||
- Think of a character set as an `OR` operation on the single characters that are enclosed between the square brackets.
|
||||
- Use `^` after the opening `[` to “negate” the character set.
|
||||
- Within a character set, `.` means a literal period.
|
||||
|
||||
### Characters that require escaping
|
||||
|
||||
#### Outside a character set
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
`\.` | period
|
||||
`\^` | caret
|
||||
`\$` | dollar sign
|
||||
`\|` | pipe
|
||||
`\\` | back slash
|
||||
`\/` | forward slash
|
||||
`\(` | opening bracket
|
||||
`\)` | closing bracket
|
||||
`\[` | opening square bracket
|
||||
`\]` | closing square bracket
|
||||
`\{` | opening curly bracket
|
||||
`\}` | closing curly bracket
|
||||
|
||||
#### Inside a character set
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
`\\` | back slash
|
||||
`\]` | closing square bracket
|
||||
|
||||
- A `^` must be escaped only if it occurs immediately after the opening `[` of the character set.
|
||||
- A `-` must be escaped only if it occurs between two alphabets or two digits.
|
||||
|
||||
### Quantifiers
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
`{2}` | exactly 2
|
||||
`{2,}` | at least 2
|
||||
`{2,7}` | at least 2 but no more than 7
|
||||
`*` | 0 or more
|
||||
`+` | 1 or more
|
||||
`?` | exactly 0 or 1
|
||||
|
||||
- The quantifier goes *after* the expression to be quantified.
|
||||
|
||||
### Boundaries
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
`^` | start of string
|
||||
`$` | end of string
|
||||
`\b` | word boundary
|
||||
|
||||
- How word boundary matching works:
|
||||
- At the beginning of the string if the first character is `\w`.
|
||||
- Between two adjacent characters within the string, if the first character is `\w` and the second character is `\W`.
|
||||
- At the end of the string if the last character is `\w`.
|
||||
|
||||
### Matching
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
`foo\|bar` | match either `foo` or `bar`
|
||||
`foo(?=bar)` | match `foo` if it’s before `bar`
|
||||
`foo(?!bar)` | match `foo` if it’s *not* before `bar`
|
||||
`(?<=bar)foo` | match `foo` if it’s after `bar`
|
||||
`(?<!bar)foo` | match `foo` if it’s *not* after `bar`
|
||||
|
||||
### Grouping and capturing
|
||||
|
||||
Expression | Description
|
||||
:--|:--
|
||||
`(foo)` | capturing group; match and capture `foo`
|
||||
`(?:foo)` | non-capturing group; match `foo` but *without* capturing `foo`
|
||||
`(foo)bar\1` | `\1` is a backreference to the 1st capturing group; match `foobarfoo`
|
||||
|
||||
- Capturing groups are only relevant in the following methods:
|
||||
- `string.match(regexp)`
|
||||
- `string.matchAll(regexp)`
|
||||
- `string.replace(regexp, callback)`
|
||||
- `\N` is a backreference to the `Nth` capturing group. Capturing groups are numbered starting from 1.
|
||||
|
||||
## References and tools
|
||||
|
||||
- [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
|
||||
- [RegExplained](https://leaverou.github.io/regexplained/)
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import { useThemeVars } from 'naive-ui';
|
||||
import Memo from './regex-memo.content.md';
|
||||
|
||||
const themeVars = useThemeVars();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Memo />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
::v-deep(pre) {
|
||||
margin: 0;
|
||||
padding: 15px 22px;
|
||||
background-color: v-bind('themeVars.cardColor');
|
||||
border-radius: 4px;
|
||||
overflow: auto;
|
||||
}
|
||||
::v-deep(table) {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
::v-deep(table), ::v-deep(td), ::v-deep(th) {
|
||||
border: 1px solid v-bind('themeVars.textColor1');
|
||||
padding: 5px;
|
||||
}
|
||||
::v-deep(a) {
|
||||
color: v-bind('themeVars.textColor1');
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Language } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Regex Tester',
|
||||
path: '/regex-tester',
|
||||
description: 'Regex Tester',
|
||||
keywords: ['regex', 'tester', 'sample', 'expression'],
|
||||
component: () => import('./regex-tester.vue'),
|
||||
icon: Language,
|
||||
createdAt: new Date('2024-09-20'),
|
||||
});
|
||||
@@ -0,0 +1,106 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { matchRegex } from './regex-tester.service';
|
||||
|
||||
const regexesData = [
|
||||
{
|
||||
regex: '',
|
||||
text: '',
|
||||
flags: '',
|
||||
result: [],
|
||||
},
|
||||
{
|
||||
regex: '.*',
|
||||
text: '',
|
||||
flags: '',
|
||||
result: [],
|
||||
},
|
||||
{
|
||||
regex: '',
|
||||
text: 'aaa',
|
||||
flags: '',
|
||||
result: [],
|
||||
},
|
||||
{
|
||||
regex: 'a',
|
||||
text: 'baaa',
|
||||
flags: '',
|
||||
result: [
|
||||
{
|
||||
captures: [],
|
||||
groups: [],
|
||||
index: 1,
|
||||
value: 'a',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
regex: '(.)(?<g>r)',
|
||||
text: 'azertyr',
|
||||
flags: 'g',
|
||||
result: [
|
||||
{
|
||||
captures: [
|
||||
{
|
||||
end: 3,
|
||||
name: '1',
|
||||
start: 2,
|
||||
value: 'e',
|
||||
},
|
||||
{
|
||||
end: 4,
|
||||
name: '2',
|
||||
start: 3,
|
||||
value: 'r',
|
||||
},
|
||||
],
|
||||
groups: [
|
||||
{
|
||||
end: 4,
|
||||
name: 'g',
|
||||
start: 3,
|
||||
value: 'r',
|
||||
},
|
||||
],
|
||||
index: 2,
|
||||
value: 'er',
|
||||
},
|
||||
{
|
||||
captures: [
|
||||
{
|
||||
end: 6,
|
||||
name: '1',
|
||||
start: 5,
|
||||
value: 'y',
|
||||
},
|
||||
{
|
||||
end: 7,
|
||||
name: '2',
|
||||
start: 6,
|
||||
value: 'r',
|
||||
},
|
||||
],
|
||||
groups: [
|
||||
{
|
||||
end: 7,
|
||||
name: 'g',
|
||||
start: 6,
|
||||
value: 'r',
|
||||
},
|
||||
],
|
||||
index: 5,
|
||||
value: 'yr',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
describe('regex-tester', () => {
|
||||
for (const reg of regexesData) {
|
||||
const { regex, text, flags, result: expected_result } = reg;
|
||||
it(`Should matchRegex("${regex}","${text}","${flags}") return correct result`, async () => {
|
||||
const result = matchRegex(regex, text, `${flags}d`);
|
||||
|
||||
expect(result).to.deep.equal(expected_result);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
interface RegExpGroupIndices {
|
||||
[name: string]: [number, number]
|
||||
}
|
||||
interface RegExpIndices extends Array<[number, number]> {
|
||||
groups: RegExpGroupIndices
|
||||
}
|
||||
interface RegExpExecArrayWithIndices extends RegExpExecArray {
|
||||
indices: RegExpIndices
|
||||
}
|
||||
interface GroupCapture {
|
||||
name: string
|
||||
value: string
|
||||
start: number
|
||||
end: number
|
||||
};
|
||||
|
||||
export function matchRegex(regex: string, text: string, flags: string) {
|
||||
// if (regex === '' || text === '') {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
let lastIndex = -1;
|
||||
const re = new RegExp(regex, flags);
|
||||
const results = [];
|
||||
let match = re.exec(text) as RegExpExecArrayWithIndices;
|
||||
while (match !== null) {
|
||||
if (re.lastIndex === lastIndex || match[0] === '') {
|
||||
break;
|
||||
}
|
||||
const indices = match.indices;
|
||||
const captures: Array<GroupCapture> = [];
|
||||
Object.entries(match).forEach(([captureName, captureValue]) => {
|
||||
if (captureName !== '0' && captureName.match(/\d+/)) {
|
||||
captures.push({
|
||||
name: captureName,
|
||||
value: captureValue,
|
||||
start: indices[Number(captureName)][0],
|
||||
end: indices[Number(captureName)][1],
|
||||
});
|
||||
}
|
||||
});
|
||||
const groups: Array<GroupCapture> = [];
|
||||
Object.entries(match.groups || {}).forEach(([groupName, groupValue]) => {
|
||||
groups.push({
|
||||
name: groupName,
|
||||
value: groupValue,
|
||||
start: indices.groups[groupName][0],
|
||||
end: indices.groups[groupName][1],
|
||||
});
|
||||
});
|
||||
results.push({
|
||||
index: match.index,
|
||||
value: match[0],
|
||||
captures,
|
||||
groups,
|
||||
});
|
||||
lastIndex = re.lastIndex;
|
||||
match = re.exec(text) as RegExpExecArrayWithIndices;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
<script setup lang="ts">
|
||||
import RandExp from 'randexp';
|
||||
import { render } from '@regexper/render';
|
||||
import type { ShadowRootExpose } from 'vue-shadow-dom';
|
||||
import { matchRegex } from './regex-tester.service';
|
||||
import { useValidation } from '@/composable/validation';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
|
||||
const regex = useQueryParamOrStorage({ name: 'regex', storageName: 'regex-tester:regex', defaultValue: '' });
|
||||
const text = ref('');
|
||||
const global = ref(true);
|
||||
const ignoreCase = ref(false);
|
||||
const multiline = ref(false);
|
||||
const dotAll = ref(true);
|
||||
const unicode = ref(true);
|
||||
const unicodeSets = ref(false);
|
||||
const visualizerSVG = ref<ShadowRootExpose>();
|
||||
|
||||
const regexValidation = useValidation({
|
||||
source: regex,
|
||||
rules: [
|
||||
{
|
||||
message: 'Invalid regex: {0}',
|
||||
validator: value => new RegExp(value),
|
||||
getErrorMessage: (value) => {
|
||||
const _ = new RegExp(value);
|
||||
return '';
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
const results = computed(() => {
|
||||
let flags = 'd';
|
||||
if (global.value) {
|
||||
flags += 'g';
|
||||
}
|
||||
if (ignoreCase.value) {
|
||||
flags += 'i';
|
||||
}
|
||||
if (multiline.value) {
|
||||
flags += 'm';
|
||||
}
|
||||
if (dotAll.value) {
|
||||
flags += 's';
|
||||
}
|
||||
if (unicode.value) {
|
||||
flags += 'u';
|
||||
}
|
||||
else if (unicodeSets.value) {
|
||||
flags += 'v';
|
||||
}
|
||||
|
||||
try {
|
||||
return matchRegex(regex.value, text.value, flags);
|
||||
}
|
||||
catch (_) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
const sample = computed(() => {
|
||||
try {
|
||||
const randexp = new RandExp(new RegExp(regex.value.replace(/\(\?\<[^\>]*\>/g, '(?:')));
|
||||
return randexp.gen();
|
||||
}
|
||||
catch (_) {
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
watchEffect(
|
||||
async () => {
|
||||
const regexValue = regex.value;
|
||||
// shadow root is required:
|
||||
// @regexper/render append a <defs><style> that broke svg transparency of icons in the whole site
|
||||
const visualizer = visualizerSVG.value?.shadow_root;
|
||||
if (visualizer) {
|
||||
while (visualizer.lastChild) {
|
||||
visualizer.removeChild(visualizer.lastChild);
|
||||
}
|
||||
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||
try {
|
||||
await render(regexValue, svg);
|
||||
}
|
||||
catch (_) {
|
||||
}
|
||||
visualizer.appendChild(svg);
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div max-w-600px>
|
||||
<c-card title="Regex" mb-1>
|
||||
<c-input-text
|
||||
v-model:value="regex"
|
||||
label="Regex to test:"
|
||||
placeholder="Put the regex to test"
|
||||
multiline
|
||||
rows="3"
|
||||
:validation="regexValidation"
|
||||
/>
|
||||
<router-link target="_blank" to="/regex-memo" mb-1 mt-1>
|
||||
See Regular Expression Cheatsheet
|
||||
</router-link>
|
||||
<n-space>
|
||||
<n-checkbox v-model:checked="global">
|
||||
<span title="Global search">Global search. (<code>g</code>)</span>
|
||||
</n-checkbox>
|
||||
<n-checkbox v-model:checked="ignoreCase">
|
||||
<span title="Case-insensitive search">Case-insensitive search. (<code>i</code>)</span>
|
||||
</n-checkbox>
|
||||
<n-checkbox v-model:checked="multiline">
|
||||
<span title="Allows ^ and $ to match next to newline characters.">Multiline(<code>m</code>)</span>
|
||||
</n-checkbox>
|
||||
<n-checkbox v-model:checked="dotAll">
|
||||
<span title="Allows . to match newline characters.">Singleline(<code>s</code>)</span>
|
||||
</n-checkbox>
|
||||
<n-checkbox v-model:checked="unicode">
|
||||
<span title="Unicode; treat a pattern as a sequence of Unicode code points.">Unicode(<code>u</code>)</span>
|
||||
</n-checkbox>
|
||||
<n-checkbox v-model:checked="unicodeSets">
|
||||
<span title="An upgrade to the u mode with more Unicode features.">Unicode Sets (<code>v</code>)</span>
|
||||
</n-checkbox>
|
||||
</n-space>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<c-input-text
|
||||
v-model:value="text"
|
||||
label="Text to match:"
|
||||
placeholder="Put the text to match"
|
||||
multiline
|
||||
rows="5"
|
||||
/>
|
||||
</c-card>
|
||||
|
||||
<c-card title="Matches" mb-1 mt-3>
|
||||
<n-table v-if="results?.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
Index in text
|
||||
</th>
|
||||
<th scope="col">
|
||||
Value
|
||||
</th>
|
||||
<th scope="col">
|
||||
Captures
|
||||
</th>
|
||||
<th scope="col">
|
||||
Groups
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="match of results" :key="match.index">
|
||||
<td>{{ match.index }}</td>
|
||||
<td>{{ match.value }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li v-for="capture in match.captures" :key="capture.name">
|
||||
"{{ capture.name }}" = {{ capture.value }} [{{ capture.start }} - {{ capture.end }}]
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li v-for="group in match.groups" :key="group.name">
|
||||
"{{ group.name }}" = {{ group.value }} [{{ group.start }} - {{ group.end }}]
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</n-table>
|
||||
<c-alert v-else>
|
||||
No match
|
||||
</c-alert>
|
||||
</c-card>
|
||||
|
||||
<c-card title="Sample matching text" mt-3>
|
||||
<pre style="white-space: pre-wrap; word-break: break-all;">{{ sample }}</pre>
|
||||
</c-card>
|
||||
|
||||
<c-card title="Regex Diagram" style="overflow-x: scroll;" mt-3>
|
||||
<shadow-root ref="visualizerSVG">
|
||||
 
|
||||
</shadow-root>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module "dom-to-image-more" {
|
||||
export function toPng(el: HTMLElement | undefined, options?: { bgcolor: string }) : Promise<string>;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Stack } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Stacktrace prettier',
|
||||
path: '/stacktrace-prettier',
|
||||
description: 'Highlight .Net and JS stacktraces',
|
||||
keywords: ['stacktrace', 'prettier', 'highlighter'],
|
||||
component: () => import('./stacktrace-prettier.vue'),
|
||||
icon: Stack,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module "javastack.js" {
|
||||
export default function javastack(selector: string, options: { prettyprint: boolean }) : void;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module "jsstack.js" {
|
||||
export default function jsstack(selector: string) : void;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
declare module "netstack.js" {
|
||||
export default class netstack {
|
||||
constructor(el: HTMLElement | undefined, options: { prettyprint: boolean })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module "pythonstack.js" {
|
||||
export default function pythonstack(selector: string, options: { prettyprint: boolean }) : void;
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
<script setup lang="ts">
|
||||
import JSStack from 'jsstack.js';
|
||||
import JavaStack from 'javastack.js';
|
||||
import PythonStack from 'pythonstack.js';
|
||||
import NetStack from 'netstack.js';
|
||||
import domtoimage from 'dom-to-image-more';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { useStyleStore } from '@/stores/style.store';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const styleStore = useStyleStore();
|
||||
|
||||
const stackType = useQueryParamOrStorage<'net' | 'js' | 'java' | 'python'>({ name: 'type', storageName: 'stackfmt:type', defaultValue: 'net' });
|
||||
const stackTrace = ref('');
|
||||
const formatedStackTrace = ref<HTMLElement>();
|
||||
|
||||
const stackTraceText = ref('');
|
||||
watchEffect(() => {
|
||||
if (!formatedStackTrace.value) {
|
||||
return;
|
||||
}
|
||||
let cleanedStackTrace;
|
||||
try {
|
||||
cleanedStackTrace = JSON.parse(stackTrace.value);
|
||||
}
|
||||
catch (_) {
|
||||
cleanedStackTrace = stackTrace.value.replace(/(\\r)?\\n/g, '\n').replace(/(?:^['"])|(?:['"]$)/, '');
|
||||
};
|
||||
try {
|
||||
if (stackType.value === 'js') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
JSStack('.stacktrace');
|
||||
}
|
||||
else if (stackType.value === 'java') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
JavaStack('.stacktrace', { prettyprint: true });
|
||||
}
|
||||
else if (stackType.value === 'python') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
PythonStack('.stacktrace', { prettyprint: true });
|
||||
}
|
||||
else if (stackType.value === 'net') {
|
||||
formatedStackTrace.value.innerText = cleanedStackTrace;
|
||||
const _ = new NetStack(formatedStackTrace.value, { prettyprint: true });
|
||||
}
|
||||
stackTraceText.value = formatedStackTrace.value.innerText;
|
||||
}
|
||||
catch {}
|
||||
});
|
||||
|
||||
const stackTraceMarkdown = computed(() => {
|
||||
let lang;
|
||||
if (stackType.value === 'net') {
|
||||
lang = 'csharp';
|
||||
}
|
||||
else if (stackType.value === 'js') {
|
||||
lang = 'javascript';
|
||||
}
|
||||
else if (stackType.value === 'java') {
|
||||
lang = 'java';
|
||||
}
|
||||
else if (stackType.value === 'python') {
|
||||
lang = 'python';
|
||||
}
|
||||
return `\`\`\`${lang}\n${formatedStackTrace.value?.innerText}\n\`\`\``;
|
||||
});
|
||||
|
||||
const { copy: copyText } = useCopy({ source: stackTraceText, text: 'Formatted stacktrace copied to the clipboard' });
|
||||
const { copy: copyMarkdown } = useCopy({ source: stackTraceMarkdown, text: 'Markdown Formatted stacktrace copied to the clipboard' });
|
||||
|
||||
async function downloadAsPNG() {
|
||||
const dataUrl = await domtoimage.toPng(formatedStackTrace.value, { bgcolor: styleStore.isDarkTheme ? '#333' : '#fff' });
|
||||
const link = document.createElement('a');
|
||||
link.download = 'stacktrace.png';
|
||||
link.href = dataUrl;
|
||||
link.click();
|
||||
}
|
||||
|
||||
const wrap = ref(true);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div max-w-600px>
|
||||
<n-radio-group v-model:value="stackType" name="radiogroup" mb-2 flex justify-center>
|
||||
<n-space>
|
||||
<n-radio
|
||||
value="net"
|
||||
label=".Net"
|
||||
/>
|
||||
<n-radio
|
||||
value="js"
|
||||
label="Javascript"
|
||||
/>
|
||||
<n-radio
|
||||
value="python"
|
||||
label="Python"
|
||||
/>
|
||||
<n-radio
|
||||
value="java"
|
||||
label="Java"
|
||||
/>
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
|
||||
<div mb-2 flex justify-center>
|
||||
<n-checkbox v-model:checked="wrap">
|
||||
Wrap lines?
|
||||
</n-checkbox>
|
||||
</div>
|
||||
<c-input-text
|
||||
v-model:value="stackTrace"
|
||||
label="Stacktrace"
|
||||
placeholder="Paste your stacktrace here.."
|
||||
multiline
|
||||
rows="5"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<pre ref="formatedStackTrace" class="stacktrace" :style="{ padding: '20px', whiteSpace: wrap ? 'pre-wrap' : 'pre', overflowX: 'auto', wordBreak: 'break-all' }" />
|
||||
|
||||
<div v-if="stackTraceText" flex justify-center gap-1>
|
||||
<c-button @click="copyText()">
|
||||
Copy Formatted (Text)
|
||||
</c-button>
|
||||
<c-button @click="copyMarkdown()">
|
||||
Copy Formatted (Markdown)
|
||||
</c-button>
|
||||
<c-button @click="downloadAsPNG()">
|
||||
Download as PNG
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
::v-deep(.stacktrace) {
|
||||
pre, code {background-color:#333 !important; color: #fff !important;}
|
||||
.st-type {color: #0a8472; font-weight: bolder;}
|
||||
.st-method {color: #70c9ba; font-weight: bolder;}
|
||||
.st-frame-params {color: #ffffff; font-weight: normal;}
|
||||
.st-param-type {color: #0a8472;}
|
||||
.st-param-name {color: #ffffff;}
|
||||
.st-file {color:#f8b068;}
|
||||
.st-line {color:#ff4f68;}
|
||||
.st-methodName {color: #70c9ba;font-weight: bolder;}
|
||||
.st-column {color: #f8b068;}
|
||||
.st-lineNumber {color: #ff4f68;}
|
||||
.st-fileName {color: #85dbff;}
|
||||
.st-intro {color: #0044dd;}
|
||||
.st-exception {color: #e40000;}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Braces } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'XML to JSON',
|
||||
path: '/xml-to-json',
|
||||
description: 'Convert XML to JSON',
|
||||
keywords: ['xml', 'json'],
|
||||
component: () => import('./xml-to-json.vue'),
|
||||
icon: Braces,
|
||||
createdAt: new Date('2024-08-09'),
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import convert from 'xml-js';
|
||||
import { isValidXML } from '../xml-formatter/xml-formatter.service';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
|
||||
const defaultValue = '<a x="1.234" y="It\'s"/>';
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => {
|
||||
return JSON.stringify(convert.xml2js(value, { compact: true }), null, 2);
|
||||
}, '');
|
||||
}
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: isValidXML,
|
||||
message: 'Provided XML is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your XML content"
|
||||
:input-default="defaultValue"
|
||||
input-placeholder="Paste your XML content here..."
|
||||
output-label="Converted JSON"
|
||||
output-language="json"
|
||||
:transformer="transformer"
|
||||
:input-validation-rules="rules"
|
||||
/>
|
||||
</template>
|
||||
Reference in new issue
Block a user