Skip to content

Commit 9b8884e

Browse files
committed
add new tool, ooxast-util-properties
1 parent 10ad30b commit 9b8884e

File tree

22 files changed

+1454
-184
lines changed

22 files changed

+1454
-184
lines changed

apps/converter-frontend/components/converted-block-local/converted-block-local.tsx

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import { Box, Button, Code, Header, Loader, Text } from '@mantine/core'
22
import { useClipboard } from '@mantine/hooks'
33
import React, { useEffect, useState } from 'react'
44
import { VFile } from 'vfile'
5-
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
5+
import { Prism as SyntaxHighlighter } from '@mantine/prism'
66
import { FaClipboard, FaClipboardList } from 'react-icons/fa'
77
import { HStack } from '../stack/stack'
88
import shallow from 'zustand/shallow'
99
import { useStore } from '../../utils/store'
10+
11+
import Prism from 'prism-react-renderer/prism'
12+
;(typeof global !== 'undefined' ? global : window).Prism = Prism
13+
14+
require('prismjs/components/prism-latex')
1015
//import { nord } from 'react-syntax-highlighter/dist/esm/styles/prism'
1116

1217
/* eslint-disable-next-line */
@@ -54,7 +59,7 @@ export function ConvertedBlockLocal(props: ConvertedBlockLocalProps) {
5459
{/* @ts-ignore */}
5560
{vfile?.messages && (
5661
<>
57-
<Header height="20">Images extracted from doc</Header>
62+
<Box height="20">Images extracted from doc</Box>
5863
<Box>
5964
{vfile?.data?.images
6065
? Object.entries(
@@ -82,7 +87,7 @@ export function ConvertedBlockLocal(props: ConvertedBlockLocalProps) {
8287
)}
8388
{vfile?.messages && (
8489
<>
85-
<Header height="20">Errors and warnings</Header>
90+
<Box height="20">Errors and warnings</Box>
8691
{vfile?.messages.map((message) => (
8792
<Text key={String(message)}>{String(message)} </Text>
8893
))}
@@ -91,16 +96,14 @@ export function ConvertedBlockLocal(props: ConvertedBlockLocalProps) {
9196
{vfile ? (
9297
<Box
9398
sx={{
94-
overflow: 'scroll',
95-
maxHeight: '70vh',
9699
paddingBottom: 20,
97-
width: 'auto',
100+
width: '100%',
98101
display: 'flex',
99102
flexDirection: 'column',
100103
alignItems: 'flex-end',
101104
}}
102105
>
103-
<Button
106+
{/* <Button
104107
style={{
105108
position: 'absolute',
106109
marginTop: 20,
@@ -116,12 +119,44 @@ export function ConvertedBlockLocal(props: ConvertedBlockLocalProps) {
116119
<FaClipboardList />
117120
<Text>{clipboard.copied ? 'Copied!' : 'Copy'}</Text>
118121
</HStack>
119-
</Button>
122+
</Button> */}
120123
<SyntaxHighlighter
121124
//wrapLines
122-
wrapLongLines
125+
withLineNumbers={true}
123126
language="latex"
124-
CodeTag={Code}
127+
// CodeTag={Code}
128+
sx={{}}
129+
style={{
130+
maxWidth: '100%',
131+
// height: '100%',
132+
maxHeight: '80vh',
133+
overflowY: 'scroll',
134+
// width: '50vw',
135+
}}
136+
// scrollAreaComponent="div"
137+
styles={{
138+
// copy: {
139+
// position: 'fixed',
140+
// top: 10,
141+
// right: 10,
142+
// },
143+
scrollArea: {
144+
width: '100%',
145+
maxHeight: '100%',
146+
// overflow: 'scroll',
147+
},
148+
code: {
149+
width: '100%',
150+
},
151+
lineContent: {
152+
width: '100%',
153+
overflowWrap: 'break-word',
154+
whiteSpace: 'pre-wrap',
155+
},
156+
line: {
157+
width: '90%',
158+
},
159+
}}
125160
//showInlineLineNumbers
126161
// style={nord}
127162
// maxW: '80%',

apps/converter-frontend/pages/_app.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { AppProps } from 'next/app'
22
import Head from 'next/head'
33
import { MantineProvider } from '@mantine/core'
4-
import React from 'react'
54
import { SWRConfig } from 'swr'
65
import { fetcher } from '../utils/fetcher'
76
import { AppShellLayout } from '../components/app-shell-layout/app-shell-layout'
@@ -29,7 +28,9 @@ export default function App(props: AppProps) {
2928
}}
3029
>
3130
<Head>
32-
<title>Covertin</title>
31+
<title>
32+
Academic Converter provided by the Center of Trial and Error
33+
</title>
3334
<meta
3435
name="viewport"
3536
content="minimum-scale=1, initial-scale=1, width=device-width"

apps/converter-frontend/utils/converters/docxToTex.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ export async function docxToTexConverter(
3838
'w:noProof',
3939
],
4040
})
41-
.use(reoffParseReferences, {
42-
apiUrl:
43-
process.env.NODE_ENV === 'production'
44-
? apiUrl || '/api/style'
45-
: process.env.NEXT_PUBLIC_STYLE_DEV_URL || 'http://localhost:8000/api/style',
46-
mailto,
47-
})
41+
// .use(reoffParseReferences, {
42+
// apiUrl:
43+
// process.env.NODE_ENV === 'production'
44+
// ? apiUrl || '/api/style'
45+
// : process.env.NEXT_PUBLIC_STYLE_DEV_URL || 'http://localhost:8000/api/style',
46+
// mailto,
47+
// })
4848
// @ts-expect-error tbh idk what it's talking about
49-
.use(reoffCite, { type: type || 'zotero', bibliography: undefined })
49+
// .use(reoffCite, { type: type || 'zotero', bibliography: undefined })
5050
.use(reoffRejour)
5151
.use(rejourStringify)
5252
.use(rejourRelatex, {
@@ -58,7 +58,7 @@ export async function docxToTexConverter(
5858
.use(relatexAddPreamble, preamble || [])
5959
.use(relatexStringify)
6060

61-
console.log(process.env.NODE_ENV)
62-
console.log(process.env.STYLE_DEV_URL)
61+
console.log(process.env.NODE_ENV)
62+
console.log(process.env.STYLE_DEV_URL)
6363
return proc.process(vfile)
6464
}

libs/jast/jast-util-to-texast/src/lib/handlers/xref.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,18 @@ export function xref(j: J, node: Xref) {
5454
let pre
5555
let post
5656
if (customType) {
57-
const customData = JSON.parse(customType)
58-
const { prefix, infix, label, locator, mode, suffix } = customData
57+
const customData: Record<string, string | undefined> =
58+
JSON.parse(customType)
59+
const {
60+
prefix,
61+
infix,
62+
label,
63+
locator,
64+
mode,
65+
suffix,
66+
plainCitation,
67+
formattedCitation,
68+
} = customData
5969

6070
const pref = (mode ? infix : prefix) || ''
6171

@@ -64,7 +74,11 @@ export function xref(j: J, node: Xref) {
6474
? `${labelToText[label] || label || 'pp.'} `
6575
: ''
6676
}${locator || ''}`
67-
command = mode ? 'textcite' : 'parencite'
77+
78+
const isParenthetical =
79+
plainCitation?.startsWith && plainCitation?.endsWith(')')
80+
81+
command = isParenthetical ? 'parencite' : 'textcite'
6882

6983
if (pref) pre = pref
7084
if (suff) post = suff
@@ -87,7 +101,7 @@ export function xref(j: J, node: Xref) {
87101
node.children
88102
.map((node) => {
89103
//@ts-expect-error it is text, it has value
90-
const n = node.value.replace(/[[\], ]/g, '')
104+
const n = node?.value?.replace(/[[\], ]/g, '')
91105
return n ? `bib${n}` : undefined
92106
})
93107
.filter((n) => !!n)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"extends": [
3+
"../../../.eslintrc.json"
4+
],
5+
"ignorePatterns": [
6+
"!**/*"
7+
],
8+
"overrides": [
9+
{
10+
"files": [
11+
"*.ts",
12+
"*.tsx",
13+
"*.js",
14+
"*.jsx"
15+
],
16+
"rules": {}
17+
},
18+
{
19+
"files": [
20+
"*.ts",
21+
"*.tsx"
22+
],
23+
"rules": {}
24+
},
25+
{
26+
"files": [
27+
"*.js",
28+
"*.jsx"
29+
],
30+
"rules": {}
31+
}
32+
]
33+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"jsc": {
3+
"target": "es2017",
4+
"parser": {
5+
"syntax": "typescript",
6+
"decorators": true,
7+
"dynamicImport": true
8+
},
9+
"transform": {
10+
"decoratorMetadata": true,
11+
"legacyDecorator": true
12+
},
13+
"keepClassNames": true,
14+
"externalHelpers": true,
15+
"loose": true
16+
},
17+
"module": {
18+
"type": "es6",
19+
"strict": true,
20+
"noInterop": true
21+
},
22+
"sourceMaps": true,
23+
"exclude": [
24+
"jest.config.ts",
25+
".*.spec.tsx?$",
26+
".*.test.tsx?$",
27+
"./src/jest-setup.ts$",
28+
"./**/jest-setup.ts$",
29+
".*.js$"
30+
]
31+
}

0 commit comments

Comments
 (0)