mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 21:44:40 +03:00
Revert "fix: remove math format converter as not possible right now"
This reverts commit 0e66063150.
This commit is contained in:
1 parent
f56a39aac3
commit
fd8b9751b1
3 files changed
+99
No files matched your search
@@ -45,6 +45,7 @@ import { tool as phpArrayToJson } from './php-array-to-json';
|
|||||||
import { tool as jsonSizeAnalyzer } from './json-size-analyzer';
|
import { tool as jsonSizeAnalyzer } from './json-size-analyzer';
|
||||||
import { tool as jsonToCsharp } from './json-to-csharp';
|
import { tool as jsonToCsharp } from './json-to-csharp';
|
||||||
import { tool as luhnValidator } from './luhn-validator';
|
import { tool as luhnValidator } from './luhn-validator';
|
||||||
|
import { tool as mathFormatsConverter } from './math-formats-converter';
|
||||||
import { tool as mathOcr } from './math-ocr';
|
import { tool as mathOcr } from './math-ocr';
|
||||||
import { tool as markdownTocGenerator } from './markdown-toc-generator';
|
import { tool as markdownTocGenerator } from './markdown-toc-generator';
|
||||||
import { tool as passphraseGenerator } from './passphrase-generator';
|
import { tool as passphraseGenerator } from './passphrase-generator';
|
||||||
@@ -493,6 +494,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
mathEvaluator,
|
mathEvaluator,
|
||||||
etaCalculator,
|
etaCalculator,
|
||||||
percentageCalculator,
|
percentageCalculator,
|
||||||
|
mathFormatsConverter,
|
||||||
mathOcr,
|
mathOcr,
|
||||||
dataTransferRateConverter,
|
dataTransferRateConverter,
|
||||||
dataStorageUnitConverter,
|
dataStorageUnitConverter,
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { EqualNot } from '@vicons/tabler';
|
||||||
|
import { defineTool } from '../tool';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: 'Math Formats Converter',
|
||||||
|
path: '/math-formats-converter',
|
||||||
|
description: 'Convert mathematical expression between formats',
|
||||||
|
keywords: ['math', 'formats', 'converter', 'latex', 'mathml', 'asciimath', 'omml', 'html'],
|
||||||
|
component: () => import('./math-formats-converter.vue'),
|
||||||
|
icon: EqualNot,
|
||||||
|
createdAt: new Date('2024-05-11'),
|
||||||
|
});
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import Plurimath from '@plurimath/plurimath';
|
||||||
|
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||||
|
|
||||||
|
const formats = [
|
||||||
|
{ value: 'asciimath', label: 'AsciiMath' },
|
||||||
|
{ value: 'latex', label: 'Latex' },
|
||||||
|
{ value: 'mathml', label: 'MathML' },
|
||||||
|
{ value: 'html', label: 'Html' },
|
||||||
|
{ value: 'omml', label: 'OOML' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const source = ref('');
|
||||||
|
const sourceFormat = useQueryParamOrStorage({ name: 'src', storageName: 'math-fmts-conv:src', defaultValue: 'latex' });
|
||||||
|
const targetFormat = useQueryParamOrStorage({ name: 'target', storageName: 'math-fmts-conv:target', defaultValue: 'mathml' });
|
||||||
|
const target = computedAsync(async () => {
|
||||||
|
const sourceValue = source.value;
|
||||||
|
const sourceFormatValue = sourceFormat.value;
|
||||||
|
const targetFormatValue = targetFormat.value;
|
||||||
|
if (sourceValue === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (sourceFormatValue === targetFormatValue) {
|
||||||
|
return sourceValue;
|
||||||
|
}
|
||||||
|
return new Promise<string>((resolve, _reject) => {
|
||||||
|
try {
|
||||||
|
const formula = new Plurimath(sourceValue, sourceFormatValue);
|
||||||
|
let result;
|
||||||
|
switch (targetFormatValue) {
|
||||||
|
case 'asciimath':
|
||||||
|
result = formula.toAsciimath();
|
||||||
|
break;
|
||||||
|
case 'latex':
|
||||||
|
result = formula.toLatex();
|
||||||
|
break;
|
||||||
|
case 'mathml':
|
||||||
|
result = formula.toMathml();
|
||||||
|
break;
|
||||||
|
case 'html':
|
||||||
|
result = formula.toHtml();
|
||||||
|
break;
|
||||||
|
case 'omml':
|
||||||
|
result = formula.toOmml();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = '# unknown format';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
|
catch (e: any) {
|
||||||
|
resolve(`# error converting formula: ${e.toString()}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<c-input-text
|
||||||
|
v-model:value="source"
|
||||||
|
multiline
|
||||||
|
placeholder="Put your math expression here..."
|
||||||
|
rows="5"
|
||||||
|
label="Mathematical expression to convert"
|
||||||
|
raw-text
|
||||||
|
mb-5
|
||||||
|
/>
|
||||||
|
<c-select
|
||||||
|
v-model:value="sourceFormat"
|
||||||
|
:options="formats"
|
||||||
|
placeholder="Source format"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<n-divider />
|
||||||
|
|
||||||
|
<c-select
|
||||||
|
v-model:value="targetFormat"
|
||||||
|
:options="formats"
|
||||||
|
placeholder="Source format"
|
||||||
|
/>
|
||||||
|
<textarea-copyable v-if="target !== ''" :value="target" :language="targetFormat" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
Reference in new issue
Block a user