mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-25 15:15:23 +03:00
feat(Math OCR): replace MathJAX by Katex
This commit is contained in:
1 parent
c4f7ded565
commit
b1d3849f87
5 files changed
+94
-55
No files matched your search
+2
-1
@@ -261,6 +261,7 @@
|
|||||||
"jsvat-next": "^3.0.4",
|
"jsvat-next": "^3.0.4",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
|
"katex": "^0.17.0",
|
||||||
"korean-unpacker": "^1.0.3",
|
"korean-unpacker": "^1.0.3",
|
||||||
"langs": "^2.0.0",
|
"langs": "^2.0.0",
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
@@ -385,11 +386,11 @@
|
|||||||
"vue-i18n": "^11.4.6",
|
"vue-i18n": "^11.4.6",
|
||||||
"vue-loading-overlay": "^6.0.6",
|
"vue-loading-overlay": "^6.0.6",
|
||||||
"vue-markdown-render": "^2.3.1",
|
"vue-markdown-render": "^2.3.1",
|
||||||
"vue-mathjax-next": "^0.0.6",
|
|
||||||
"vue-router": "^5.1.0",
|
"vue-router": "^5.1.0",
|
||||||
"vue-shadow-dom": "^4.2.0",
|
"vue-shadow-dom": "^4.2.0",
|
||||||
"vue-tsc": "^3.3.6",
|
"vue-tsc": "^3.3.6",
|
||||||
"vue3-flip-countdown": "^0.1.6",
|
"vue3-flip-countdown": "^0.1.6",
|
||||||
|
"vue3-katex": "^0.8.1",
|
||||||
"vuedraggable": "^4.1.0",
|
"vuedraggable": "^4.1.0",
|
||||||
"vuex": "^4.1.0",
|
"vuex": "^4.1.0",
|
||||||
"w-websocket-client": "^1.0.29",
|
"w-websocket-client": "^1.0.29",
|
||||||
|
|||||||
Generated
+37
-8
@@ -672,6 +672,9 @@ importers:
|
|||||||
jwt-decode:
|
jwt-decode:
|
||||||
specifier: ^4.0.0
|
specifier: ^4.0.0
|
||||||
version: 4.0.0
|
version: 4.0.0
|
||||||
|
katex:
|
||||||
|
specifier: ^0.17.0
|
||||||
|
version: 0.17.0
|
||||||
korean-unpacker:
|
korean-unpacker:
|
||||||
specifier: ^1.0.3
|
specifier: ^1.0.3
|
||||||
version: 1.0.3
|
version: 1.0.3
|
||||||
@@ -1044,9 +1047,6 @@ importers:
|
|||||||
vue-markdown-render:
|
vue-markdown-render:
|
||||||
specifier: ^2.3.1
|
specifier: ^2.3.1
|
||||||
version: 2.3.1(vue@3.5.39(typescript@6.0.3))
|
version: 2.3.1(vue@3.5.39(typescript@6.0.3))
|
||||||
vue-mathjax-next:
|
|
||||||
specifier: ^0.0.6
|
|
||||||
version: 0.0.6
|
|
||||||
vue-router:
|
vue-router:
|
||||||
specifier: ^5.1.0
|
specifier: ^5.1.0
|
||||||
version: 5.1.0(@vue/compiler-sfc@3.5.39)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.39(typescript@6.0.3)))(rolldown@1.1.4)(rollup@4.62.2)(vite@8.1.3(@types/node@24.13.3)(jiti@2.7.0)(less@4.6.7)(terser@5.48.0)(yaml@2.9.0))(vue@3.5.39(typescript@6.0.3))(webpack@5.108.3(postcss@8.5.16))
|
version: 5.1.0(@vue/compiler-sfc@3.5.39)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.39(typescript@6.0.3)))(rolldown@1.1.4)(rollup@4.62.2)(vite@8.1.3(@types/node@24.13.3)(jiti@2.7.0)(less@4.6.7)(terser@5.48.0)(yaml@2.9.0))(vue@3.5.39(typescript@6.0.3))(webpack@5.108.3(postcss@8.5.16))
|
||||||
@@ -1059,6 +1059,9 @@ importers:
|
|||||||
vue3-flip-countdown:
|
vue3-flip-countdown:
|
||||||
specifier: ^0.1.6
|
specifier: ^0.1.6
|
||||||
version: 0.1.6(typescript@6.0.3)
|
version: 0.1.6(typescript@6.0.3)
|
||||||
|
vue3-katex:
|
||||||
|
specifier: ^0.8.1
|
||||||
|
version: 0.8.1(katex@0.17.0)(vue@3.5.39(typescript@6.0.3))
|
||||||
vuedraggable:
|
vuedraggable:
|
||||||
specifier: ^4.1.0
|
specifier: ^4.1.0
|
||||||
version: 4.1.0(vue@3.5.39(typescript@6.0.3))
|
version: 4.1.0(vue@3.5.39(typescript@6.0.3))
|
||||||
@@ -8188,6 +8191,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-Eeo8Ys1doU1z+x8AZsPpQu+p/QcZBI5PeOo7QGQdy2x2m0MU/hYagBbGOmXwr5KVbEfVuWv9LpnQWeehogurjg==}
|
resolution: {integrity: sha512-Eeo8Ys1doU1z+x8AZsPpQu+p/QcZBI5PeOo7QGQdy2x2m0MU/hYagBbGOmXwr5KVbEfVuWv9LpnQWeehogurjg==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
katex@0.17.0:
|
||||||
|
resolution: {integrity: sha512-Vdw0ATsQ9V+LuegM/BTwQqV/6cTl5lbGcIrU+BCgLxyf6bo38ybOr372tuSIxir3CN720flu1meYR6XzNMwQnw==}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
keycode@2.2.1:
|
keycode@2.2.1:
|
||||||
resolution: {integrity: sha512-Rdgz9Hl9Iv4QKi8b0OlCRQEzp4AgVxyCtz5S/+VIHezDmrDhkp2N2TqBWOLz0/gbeREXOOiI9/4b8BY9uw2vFg==}
|
resolution: {integrity: sha512-Rdgz9Hl9Iv4QKi8b0OlCRQEzp4AgVxyCtz5S/+VIHezDmrDhkp2N2TqBWOLz0/gbeREXOOiI9/4b8BY9uw2vFg==}
|
||||||
|
|
||||||
@@ -11128,6 +11135,11 @@ packages:
|
|||||||
'@vue/composition-api':
|
'@vue/composition-api':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
vue-dompurify-html@5.3.0:
|
||||||
|
resolution: {integrity: sha512-HJQGBHbfSPcb6Mu97McdKbX7TqRHZa6Ji8OCpCNyuHca5QvQZ8IiuwghFPSO8OkSQfqXPNPKFMZdCOrnGGmOSQ==}
|
||||||
|
peerDependencies:
|
||||||
|
vue: ^3.4.36
|
||||||
|
|
||||||
vue-i18n-extract@2.0.7:
|
vue-i18n-extract@2.0.7:
|
||||||
resolution: {integrity: sha512-i1NW5R58S720iQ1BEk+6ILo3hT6UA8mtYNNolSH4rt9345qvXdvA6GHy2+jHozdDAKHwlu9VvS/+vIMKs1UYQw==}
|
resolution: {integrity: sha512-i1NW5R58S720iQ1BEk+6ILo3hT6UA8mtYNNolSH4rt9345qvXdvA6GHy2+jHozdDAKHwlu9VvS/+vIMKs1UYQw==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
@@ -11149,9 +11161,6 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.3.4
|
vue: ^3.3.4
|
||||||
|
|
||||||
vue-mathjax-next@0.0.6:
|
|
||||||
resolution: {integrity: sha512-H4nZ8t31TmBJgiR6pHrOGz+RWhlw34d0yhD8fi8CnXoGOydGFreNH/Crd/9Jfd2IMSu/I0AC3ymT9D09JRMIrw==}
|
|
||||||
|
|
||||||
vue-router@5.1.0:
|
vue-router@5.1.0:
|
||||||
resolution: {integrity: sha512-HAbiLzLEHQwxPgvsbOJDAwtavszEgLwri6XfyrsPECIFez8+59xc9LofWVdc/HEaSRT822lJ8H9Ns38VVond5g==}
|
resolution: {integrity: sha512-HAbiLzLEHQwxPgvsbOJDAwtavszEgLwri6XfyrsPECIFez8+59xc9LofWVdc/HEaSRT822lJ8H9Ns38VVond5g==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -11185,6 +11194,12 @@ packages:
|
|||||||
vue3-flip-countdown@0.1.6:
|
vue3-flip-countdown@0.1.6:
|
||||||
resolution: {integrity: sha512-RRz+iZ7Zvr1U9mrZRya7I5815jboDyRJz9vzgILq8ZCc2fQ6SxZPYwOr3pD5oWCDBprAEsPF9x4fsTtEitSmXw==}
|
resolution: {integrity: sha512-RRz+iZ7Zvr1U9mrZRya7I5815jboDyRJz9vzgILq8ZCc2fQ6SxZPYwOr3pD5oWCDBprAEsPF9x4fsTtEitSmXw==}
|
||||||
|
|
||||||
|
vue3-katex@0.8.1:
|
||||||
|
resolution: {integrity: sha512-d6wxMHHaogxk6BZ+Ek/sY4AJPGfwebtCtvKWtQY+paqzhA8DpRW3gHFv9fnCxsPEXLKuYcNCqFgekJ4k8S6EKw==}
|
||||||
|
peerDependencies:
|
||||||
|
katex: ^0.17.0
|
||||||
|
vue: ^3.2.22
|
||||||
|
|
||||||
vue@3.5.39:
|
vue@3.5.39:
|
||||||
resolution: {integrity: sha512-xmZCYabFGcirU8r0fTuvl/LICc1OU620rnqepaJDL/a141ZigkG7AyaxQLdqJ02ZRYzWe6YPaDHeQx7MfknQfA==}
|
resolution: {integrity: sha512-xmZCYabFGcirU8r0fTuvl/LICc1OU620rnqepaJDL/a141ZigkG7AyaxQLdqJ02ZRYzWe6YPaDHeQx7MfknQfA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -19001,6 +19016,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
commander: 8.3.0
|
commander: 8.3.0
|
||||||
|
|
||||||
|
katex@0.17.0:
|
||||||
|
dependencies:
|
||||||
|
commander: 8.3.0
|
||||||
|
|
||||||
keycode@2.2.1: {}
|
keycode@2.2.1: {}
|
||||||
|
|
||||||
keycon@1.4.0:
|
keycon@1.4.0:
|
||||||
@@ -22309,6 +22328,11 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
vue: 3.5.39(typescript@6.0.3)
|
vue: 3.5.39(typescript@6.0.3)
|
||||||
|
|
||||||
|
vue-dompurify-html@5.3.0(vue@3.5.39(typescript@6.0.3)):
|
||||||
|
dependencies:
|
||||||
|
dompurify: 3.4.12
|
||||||
|
vue: 3.5.39(typescript@6.0.3)
|
||||||
|
|
||||||
vue-i18n-extract@2.0.7:
|
vue-i18n-extract@2.0.7:
|
||||||
dependencies:
|
dependencies:
|
||||||
cac: 6.7.14
|
cac: 6.7.14
|
||||||
@@ -22334,8 +22358,6 @@ snapshots:
|
|||||||
markdown-it: 14.3.0
|
markdown-it: 14.3.0
|
||||||
vue: 3.5.39(typescript@6.0.3)
|
vue: 3.5.39(typescript@6.0.3)
|
||||||
|
|
||||||
vue-mathjax-next@0.0.6: {}
|
|
||||||
|
|
||||||
vue-router@5.1.0(@vue/compiler-sfc@3.5.39)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.39(typescript@6.0.3)))(rolldown@1.1.4)(rollup@4.62.2)(vite@8.1.3(@types/node@24.13.3)(jiti@2.7.0)(less@4.6.7)(terser@5.48.0)(yaml@2.9.0))(vue@3.5.39(typescript@6.0.3))(webpack@5.108.3(postcss@8.5.16)):
|
vue-router@5.1.0(@vue/compiler-sfc@3.5.39)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.39(typescript@6.0.3)))(rolldown@1.1.4)(rollup@4.62.2)(vite@8.1.3(@types/node@24.13.3)(jiti@2.7.0)(less@4.6.7)(terser@5.48.0)(yaml@2.9.0))(vue@3.5.39(typescript@6.0.3))(webpack@5.108.3(postcss@8.5.16)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/generator': 8.0.0
|
'@babel/generator': 8.0.0
|
||||||
@@ -22386,6 +22408,13 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
|
vue3-katex@0.8.1(katex@0.17.0)(vue@3.5.39(typescript@6.0.3)):
|
||||||
|
dependencies:
|
||||||
|
deepmerge: 4.3.1
|
||||||
|
katex: 0.17.0
|
||||||
|
vue: 3.5.39(typescript@6.0.3)
|
||||||
|
vue-dompurify-html: 5.3.0(vue@3.5.39(typescript@6.0.3))
|
||||||
|
|
||||||
vue@3.5.39(typescript@6.0.3):
|
vue@3.5.39(typescript@6.0.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vue/compiler-dom': 3.5.39
|
'@vue/compiler-dom': 3.5.39
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import { plausible } from './plugins/plausible.plugin';
|
|||||||
import '@/utils/json5-bigint';
|
import '@/utils/json5-bigint';
|
||||||
import '@/utils/json5-bignum';
|
import '@/utils/json5-bignum';
|
||||||
|
|
||||||
|
import Vue3Katex from 'vue3-katex';
|
||||||
|
import 'katex/dist/katex.min.css';
|
||||||
|
|
||||||
import 'virtual:uno.css';
|
import 'virtual:uno.css';
|
||||||
|
|
||||||
import { naive } from './plugins/naive.plugin';
|
import { naive } from './plugins/naive.plugin';
|
||||||
@@ -49,5 +52,6 @@ app.use(naive);
|
|||||||
app.use(plausible);
|
app.use(plausible);
|
||||||
app.use(shadow);
|
app.use(shadow);
|
||||||
app.use(store, 'pomodoro-store');
|
app.use(store, 'pomodoro-store');
|
||||||
|
app.use(Vue3Katex);
|
||||||
|
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
Vendored
+37
-29
@@ -1,11 +1,11 @@
|
|||||||
declare module '*.vue' {
|
declare module '*.vue' {
|
||||||
import type { ComponentOptions } from 'vue';
|
import type { ComponentOptions } from 'vue';
|
||||||
const Component: ComponentOptions;
|
const Component: ComponentOptions;
|
||||||
export default Component;
|
export default Component;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module '*.md' {
|
declare module '*.md' {
|
||||||
import type { ComponentOptions } from 'vue';
|
import type { ComponentOptions } from 'vue';
|
||||||
const Component: ComponentOptions;
|
const Component: ComponentOptions;
|
||||||
export default Component;
|
export default Component;
|
||||||
}
|
}
|
||||||
@@ -27,31 +27,34 @@ declare module 'emojilib' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare module 'unicode-emoji-json' {
|
declare module 'unicode-emoji-json' {
|
||||||
const emoji: Record<string, {
|
const emoji: Record<
|
||||||
name: string;
|
string,
|
||||||
slug: string;
|
{
|
||||||
group: string;
|
name: string;
|
||||||
emoji_version: string;
|
slug: string;
|
||||||
unicode_version: string;
|
group: string;
|
||||||
skin_tone_support: boolean;
|
emoji_version: string;
|
||||||
skin_tone_support_unicode_version: string;
|
unicode_version: string;
|
||||||
}>;
|
skin_tone_support: boolean;
|
||||||
|
skin_tone_support_unicode_version: string;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
|
||||||
export default emoji;
|
export default emoji;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'pdf-signature-reader' {
|
declare module 'pdf-signature-reader' {
|
||||||
const verifySignature: (pdf: ArrayBuffer) => ({signatures: SignatureInfo[]});
|
const verifySignature: (pdf: ArrayBuffer) => { signatures: SignatureInfo[] };
|
||||||
|
|
||||||
export default verifySignature;
|
export default verifySignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'units-converter' {
|
declare module 'units-converter' {
|
||||||
interface ITo{
|
interface ITo {
|
||||||
to(unit: string): { value: number }
|
to(unit: string): { value: number };
|
||||||
}
|
}
|
||||||
interface IFrom{
|
interface IFrom {
|
||||||
from(unit: string): ITo
|
from(unit: string): ITo;
|
||||||
}
|
}
|
||||||
export function frequency(value: number): IFrom;
|
export function frequency(value: number): IFrom;
|
||||||
export function volumeFlowRate(value: number): IFrom;
|
export function volumeFlowRate(value: number): IFrom;
|
||||||
@@ -64,7 +67,7 @@ interface BigInt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface JSON {
|
interface JSON {
|
||||||
parseBigInt: (jsonStr: string, options?: { minDigits?: number; }) => any;
|
parseBigInt: (jsonStr: string, options?: { minDigits?: number }) => any;
|
||||||
parseBigNum: (jsonStr: string) => any;
|
parseBigNum: (jsonStr: string) => any;
|
||||||
rawJSON(value: string): any;
|
rawJSON(value: string): any;
|
||||||
}
|
}
|
||||||
@@ -74,7 +77,7 @@ interface Navigator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface FontFaceSet {
|
interface FontFaceSet {
|
||||||
add(fontFace: FontFace)
|
add(fontFace: FontFace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove once https://github.com/microsoft/TypeScript/issues/60608 is resolved
|
// TODO remove once https://github.com/microsoft/TypeScript/issues/60608 is resolved
|
||||||
@@ -88,8 +91,8 @@ namespace Intl {
|
|||||||
|
|
||||||
declare module '@vueuse/integrations/useIDBKeyval' {
|
declare module '@vueuse/integrations/useIDBKeyval' {
|
||||||
interface Serializer<T> {
|
interface Serializer<T> {
|
||||||
read: (raw: unknown) => T
|
read: (raw: unknown) => T;
|
||||||
write: (value: T) => unknown
|
write: (value: T) => unknown;
|
||||||
}
|
}
|
||||||
export interface UseIDBOptions<T> extends ConfigurableFlush {
|
export interface UseIDBOptions<T> extends ConfigurableFlush {
|
||||||
/**
|
/**
|
||||||
@@ -97,34 +100,34 @@ declare module '@vueuse/integrations/useIDBKeyval' {
|
|||||||
*
|
*
|
||||||
* @default true
|
* @default true
|
||||||
*/
|
*/
|
||||||
deep?: boolean
|
deep?: boolean;
|
||||||
/**
|
/**
|
||||||
* On error callback
|
* On error callback
|
||||||
*
|
*
|
||||||
* Default log error to `console.error`
|
* Default log error to `console.error`
|
||||||
*/
|
*/
|
||||||
onError?: (error: unknown) => void
|
onError?: (error: unknown) => void;
|
||||||
/**
|
/**
|
||||||
* Use shallow ref as reference
|
* Use shallow ref as reference
|
||||||
*
|
*
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
shallow?: boolean
|
shallow?: boolean;
|
||||||
/**
|
/**
|
||||||
* Write the default value to the storage when it does not exist
|
* Write the default value to the storage when it does not exist
|
||||||
*
|
*
|
||||||
* @default true
|
* @default true
|
||||||
*/
|
*/
|
||||||
writeDefaults?: boolean
|
writeDefaults?: boolean;
|
||||||
/**
|
/**
|
||||||
* Custom data serialization
|
* Custom data serialization
|
||||||
*/
|
*/
|
||||||
serializer?: Serializer<T>
|
serializer?: Serializer<T>;
|
||||||
}
|
}
|
||||||
export interface UseIDBKeyvalReturn<T> {
|
export interface UseIDBKeyvalReturn<T> {
|
||||||
data: RemovableRef<T>
|
data: RemovableRef<T>;
|
||||||
isFinished: ShallowRef<boolean>
|
isFinished: ShallowRef<boolean>;
|
||||||
set: (value: T) => Promise<void>
|
set: (value: T) => Promise<void>;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -136,5 +139,10 @@ declare module '@vueuse/integrations/useIDBKeyval' {
|
|||||||
key: IDBValidKey,
|
key: IDBValidKey,
|
||||||
initialValue: MaybeRefOrGetter<T>,
|
initialValue: MaybeRefOrGetter<T>,
|
||||||
options?: UseIDBOptions<T>,
|
options?: UseIDBOptions<T>,
|
||||||
): UseIDBKeyvalReturn<T>
|
): UseIDBKeyvalReturn<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'vue3-katex' {
|
||||||
|
const Vue3Katex: (app: App, props?: Props, slots?: Slots) => void;
|
||||||
|
export default Vue3Katex;
|
||||||
}
|
}
|
||||||
@@ -2,21 +2,17 @@
|
|||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import type { Ref } from 'vue';
|
import type { Ref } from 'vue';
|
||||||
import { pipeline } from '@huggingface/transformers';
|
import { pipeline } from '@huggingface/transformers';
|
||||||
import VueMathjax from 'vue-mathjax-next';
|
|
||||||
import { useScriptTag } from '@vueuse/core';
|
import { useScriptTag } from '@vueuse/core';
|
||||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
useScriptTag('//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_HTML');
|
|
||||||
|
|
||||||
const ocrInProgress = ref(false);
|
const ocrInProgress = ref(false);
|
||||||
const fileInput = ref() as Ref<File>;
|
const fileInput = ref() as Ref<File>;
|
||||||
const latexResult = computedAsync(async () => {
|
const latexResult = computedAsync(async () => {
|
||||||
try {
|
try {
|
||||||
return (await ocr(fileInput.value));
|
return await ocr(fileInput.value);
|
||||||
}
|
} catch (e: any) {
|
||||||
catch (e: any) {
|
|
||||||
return e.toString();
|
return e.toString();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -32,7 +28,7 @@ function toBase64(file: File) {
|
|||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
reader.onload = () => resolve(reader.result?.toString() ?? '');
|
reader.onload = () => resolve(reader.result?.toString() ?? '');
|
||||||
reader.onerror = error => reject(error);
|
reader.onerror = (error) => reject(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,14 +46,15 @@ async function ocr(file: File) {
|
|||||||
const out: TexifyResult = (await pipe(imgBase64, { max_new_tokens: 384 })) as TexifyResult;
|
const out: TexifyResult = (await pipe(imgBase64, { max_new_tokens: 384 })) as TexifyResult;
|
||||||
|
|
||||||
ocrInProgress.value = false;
|
ocrInProgress.value = false;
|
||||||
return out.map(t => t.generated_text).join('\n');
|
return out.map((t) => t.generated_text).join('\n');
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<c-alert type="warning" mb-2>
|
<c-alert type="warning" mb-2>
|
||||||
{{ t('tools.math-ocr.texts.tag-nb-processing-is-done-in-your-browser-so-be-patient-processing-can-take-a-while') }}<br>{{ t('tools.math-ocr.texts.tag-this-tool-required-internet-connection-to-access-models') }}
|
{{ t('tools.math-ocr.texts.tag-nb-processing-is-done-in-your-browser-so-be-patient-processing-can-take-a-while')
|
||||||
|
}}<br />{{ t('tools.math-ocr.texts.tag-this-tool-required-internet-connection-to-access-models') }}
|
||||||
</c-alert>
|
</c-alert>
|
||||||
|
|
||||||
<c-file-upload
|
<c-file-upload
|
||||||
@@ -73,21 +70,21 @@ async function ocr(file: File) {
|
|||||||
<TextareaCopyable
|
<TextareaCopyable
|
||||||
v-if="!ocrInProgress"
|
v-if="!ocrInProgress"
|
||||||
v-model:value="latexResult"
|
v-model:value="latexResult"
|
||||||
:word-wrap="true" mb-2
|
:word-wrap="true"
|
||||||
|
mb-2
|
||||||
download-file-name="output.tex"
|
download-file-name="output.tex"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div style="text-align: center">
|
<div style="text-align: center">
|
||||||
<VueMathjax
|
<katex-element
|
||||||
v-if="!ocrInProgress"
|
v-if="!ocrInProgress"
|
||||||
:formula="latexResult"
|
:expression="latexResult?.replace(/\$\$$|^\$\$/g, '')"
|
||||||
|
:throw-on-error="false"
|
||||||
|
:strict="false"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<n-spin
|
<n-spin v-if="ocrInProgress" size="small" />
|
||||||
v-if="ocrInProgress"
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in new issue
Block a user