-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processors-jote-docx-tex.ts
executable file
·51 lines (47 loc) · 1.38 KB
/
processors-jote-docx-tex.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import reoffParse from 'reoff-parse'
import reoffRejour from 'reoff-rejour'
import rejourRelatex from 'rejour-relatex'
import relatexStringify from 'relatex-stringify'
import relatexAddPreamble from 'relatex-add-preamble'
import { docxToVFile } from 'docx-to-vfile'
import { unified } from 'unified'
import { reoffClean } from 'reoff-clean'
import reoffCite from 'reoff-cite'
import reoffParseReferences from 'reoff-parse-references'
import { VFile } from 'vfile'
import { Options } from 'ooxast-util-citations'
export async function docxToTex(
input: Uint8Array,
options: {
citationType?: 'mendeley' | 'native' | 'citavi' | 'zotero' | 'endnote'
url?: string
mailto?: string
} = {}
): Promise<VFile> {
const vfile = await docxToVFile(input)
const { citationType: type, url: apiUrl, mailto } = options
const proc = unified()
.use(reoffParse)
.use(reoffClean, {
rPrRemoveList: [
'w:lang',
'w:shd',
'w:szCs',
'w:kern',
'w:rFonts',
'w:noProof',
],
})
.use(reoffParseReferences, { apiUrl, mailto })
.use(reoffCite, { type: type ?? 'mendeley' } as Options)
.use(reoffRejour)
.use(rejourRelatex, {
documentClass: {
name: 'jote-new-article',
options: ['empirical', 'authordate'],
},
})
.use(relatexAddPreamble, [])
.use(relatexStringify)
return proc.process(vfile)
}