Note This repository is automatically generated from the main parser monorepo. Please submit any issues or pull requests there.
Convert ooxast
syntax tree to unified-latex
syntax tree.
This package is a utility that takes an ooxast (docx) syntax tree as input and turns it into a unified-latex (LaTeX) syntax tree.
This project is useful when you want to deal with ASTs and turn OOXML into LaTeX.
The reoff plugin [reoff-unified-latex] wraps this utility to also turn markdown to HTML at a higher-level (easier) abstraction.
This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install as
pnpm add ooxast-util-to-unified-latex
# or with yarn
# yarn add ooxast-util-to-unified-latex
# or with npm
# npm install ooxast-util-to-unified-latex
toUnifiedLatex(tree: Element | Text | Root, file: VFile, options?: Options): UnifiedLatexRoot;
Name | Type |
---|---|
tree |
Element |
file |
VFile |
options? |
Options |
UnifiedLatexRoot
Defined in: src/lib/ooxast-util-to-unified-latex.ts:62
toUnifiedLatex(tree: Element | Text | Root, options?: Options): UnifiedLatexRoot;
Name | Type |
---|---|
tree |
Element |
options? |
Options |
UnifiedLatexRoot
Defined in: src/lib/ooxast-util-to-unified-latex.ts:67
string
|Data
[]
A bibliography you can add manually
Needs to be in CSL format, which will be converted to BibTeX, or in BibTeX format
Defined in: src/lib/types.ts:146
string
Name of the bibliography file
'bibliography.bib'
Defined in: src/lib/types.ts:47
"endnote"
|"mendeley"
|"word"
|"citavi"
|"zotero"
What type of citation is used?
'zotero'
Defined in: src/lib/types.ts:70
Function
Signature`
(citation: any, index: string | number): any;
Parameters`
Name | Type |
---|---|
citation |
any |
index |
string |
Returns`
any
Defined in: src/lib/types.ts:72
boolean
Should a column separator be added to tables?
i.e. should |
be added to the beginning and end of each row?
false
Defined in: src/lib/types.ts:52
string
What column should be used as the default column?
e.g l
for left, r
for right, c
for center
'l'
Defined in: src/lib/types.ts:127
"align"
|"equation"
|"equation*"
|"align*"
|"$$"
|"[]"
What type of display math should be used?
-$$
: $$ ... $$
-[]
: [ ... \]
-equation
| equation*
| align
| align*
: \begin{...} ... \end{...}
'equation'
Defined in: src/lib/types.ts:86
boolean
Defined in: src/lib/types.ts:27
object
{
name: string;
options?: string[];
}
Options for the document class
Member | Type | Description |
---|---|---|
name |
string |
Name of the document class Default 'article' |
options ? |
string [] |
Options for the document class Default undefined |
Defined in: src/lib/types.ts:56
object
Handlers for specific node types
Defined in: src/lib/types.ts:26
"$"
|"()"
What type of inline math should be used?
-$
: $ ... $
-()
: \(...\)
'$'
Defined in: src/lib/types.ts:102
"emph"
|"textit"
Should italics be rendered as \textit or \emph?
'emph'
Defined in: src/lib/types.ts:43
boolean
Defined in: src/lib/types.ts:28
(
string
| {name
:string
;options
:string
[]; })[]
A list of packages to add to the preamble
by default, the following packages are added:
xcolor
(ifxcolor
is enabled)hyperref
graphicx
caption
tabularx
(iftabularx
is enabled)
Defined in: src/lib/types.ts:158
Function
Signature`
(citation: any): any;
Parameters`
Name | Type |
---|---|
citation |
any |
Returns`
any
Defined in: src/lib/types.ts:71
string
|UnifiedLatexNode
[]
A list of commands and other stuff to add to the preamble
You are responsible for making sure that the commands are valid LaTeX and that they can be used in the preamble.
You need to directly use the unified-latex types here, or you can just put it in raw
'\title{}'
import { m, args } from '@unified-latex/unified-latex-types'
const options = {
preamble: [
// \author{Leeroy Jenkins}
m('author', 'Leeroy Jenkins'),
// \title{The Adventures of Leeroy Jenkins}
m('title', 'The Adventures of Leeroy Jenkins'),
// \somemacrowithoptions[optional1][optional2]{firstArg}{secondArg}
m(
'somemacrowithoptions',
args(
['optional1', 'optional2', 'firstArg', 'secondArg'],
{ braces: '[][]{}{}'}
)
),
]
}
Defined in: src/lib/types.ts:192
string
[]
Defined in: src/lib/types.ts:29
object
Defined in: src/lib/types.ts:74
"st"
|"sout"
|"s"
Defined in: src/lib/types.ts:103
boolean
| {width
?:string
; }
Should tabularx be used instead of tabular?
false
Defined in: src/lib/types.ts:132
string
The title of the document
If this is not set, the title will be taken from the heading with the "Title" style.
undefined
Defined in: src/lib/types.ts:119
number
What the top section should be -1 = part 0 = chapter 1 = section 2 = subsection 3 = subsubsection 4 = paragraph 5 = subparagraph
Defined in: src/lib/types.ts:39
boolean
Are you using xcolor?
Disabling this will remove the xcolor
package from the preamble
and remove color related commands from the output.
true
Defined in: src/lib/types.ts:111
HWithProps
&HWithoutProps
&Context
Defined in: src/lib/types.ts:292
Function
(h: H, node: any, parent?: Parent): UnifiedLatexNode | UnifiedLatexNode[] | void | undefined;
Name | Type |
---|---|
h |
H |
node |
any |
parent? |
Parent |
UnifiedLatexNode
| UnifiedLatexNode
[] | void
| undefined
Defined in: src/lib/types.ts:195
Root
|String
|Whitespace
|Parbreak
|Comment
|Macro
|Environment
|VerbatimEnvironment
|InlineMath
|DisplayMath
|Group
|Verb
Defined in: node_modules/.pnpm/@[email protected]/node_modules/@unified-latex/unified-latex-types/libs/ast-types.d.ts:83
Convert all nodes in tree using j
all(h: H, parent: Parent<Node<Data>, Data> | Node): UnifiedLatexNode[];
Name | Type | Description | |
---|---|---|---|
h |
H |
ooxast constructor function | |
parent |
Parent <Node <Data >, Data > |
Node |
Defined in: src/lib/all.ts:10
one(h: H, node: Node, parent?: Parent<Node<Data>, Data>): UnifiedLatexNode | UnifiedLatexNode[] | void;
Name | Type |
---|---|
h |
H |
node |
Node |
parent? |
Parent <Node <Data >, Data > |
UnifiedLatexNode
| UnifiedLatexNode
[] | void
Defined in: src/lib/one.ts:8
toUnifiedLatex(tree: Element | Text | Root, options: Options): Root;
Name | Type | ||
---|---|---|---|
tree |
Element |
Text |
Root |
options |
Options |
Root
Defined in: src/lib/ooxast-util-to-unified-latex.ts:45
Const
Context
["handlers"
]
Defined in: src/lib/handlers/index.ts:20
string
|Data
[]
A bibliography you can add manually
Needs to be in CSL format, which will be converted to BibTeX, or in BibTeX format
Defined in: src/lib/types.ts:147
string
Name of the bibliography file
'bibliography.bib'
Defined in: src/lib/types.ts:48
"endnote"
|"mendeley"
|"word"
|"citavi"
|"zotero"
What type of citation is used?
'zotero'
Defined in: src/lib/types.ts:71
Function
Signature`
(citation: any, index: string | number): any;
Parameters`
Name | Type | |
---|---|---|
citation |
any |
|
index |
string |
number |
Returns`
any
Defined in: src/lib/types.ts:73
boolean
Should a column separator be added to tables?
i.e. should |
be added to the beginning and end of each row?
false
Defined in: src/lib/types.ts:53
string
What column should be used as the default column?
e.g l
for left, r
for right, c
for center
'l'
Defined in: src/lib/types.ts:128
"align"
|"equation"
|"equation*"
|"align*"
|"$$"
|"[]"
What type of display math should be used?
-$$
: $$ ... $$
-[]
: [ ... \]
-equation
| equation*
| align
| align*
: \begin{...} ... \end{...}
'equation'
Defined in: src/lib/types.ts:87
boolean
Defined in: src/lib/types.ts:28
object
{
name: string;
options?: string[];
}
Options for the document class
Member | Type | Description |
---|---|---|
name |
string |
Name of the document class Default 'article' |
options ? |
string [] |
Options for the document class Default undefined |
Defined in: src/lib/types.ts:57
object
Handlers for specific node types
Defined in: src/lib/types.ts:27
"$"
|"()"
What type of inline math should be used?
-$
: $ ... $
-()
: \(...\)
'$'
Defined in: src/lib/types.ts:103
"emph"
|"textit"
Should italics be rendered as \textit or \emph?
'emph'
Defined in: src/lib/types.ts:44
boolean
Defined in: src/lib/types.ts:29
(
string
| {name
:string
;options
:string
[]; })[]
A list of packages to add to the preamble
by default, the following packages are added:
xcolor
(ifxcolor
is enabled)hyperref
graphicx
caption
tabularx
(iftabularx
is enabled)
Defined in: src/lib/types.ts:159
Function
Signature`
(citation: any): any;
Parameters`
Name | Type |
---|---|
citation |
any |
Returns`
any
Defined in: src/lib/types.ts:72
string
|UnifiedLatexNode
[]
A list of commands and other stuff to add to the preamble
You are responsible for making sure that the commands are valid LaTeX and that they can be used in the preamble.
You need to directly use the unified-latex types here, or you can just put it in raw
'\title{}'
import { m, args } from '@unified-latex/unified-latex-types'
const options = {
preamble: [
// \author{Leeroy Jenkins}
m('author', 'Leeroy Jenkins'),
// \title{The Adventures of Leeroy Jenkins}
m('title', 'The Adventures of Leeroy Jenkins'),
// \somemacrowithoptions[optional1][optional2]{firstArg}{secondArg}
m(
'somemacrowithoptions',
args(
['optional1', 'optional2', 'firstArg', 'secondArg'],
{ braces: '[][]{}{}'}
)
),
]
}
Defined in: src/lib/types.ts:193
string
[]
Defined in: src/lib/types.ts:30
object
Defined in: src/lib/types.ts:75
"st"
|"sout"
|"s"
Defined in: src/lib/types.ts:104
boolean
| {width
?:string
; }
Should tabularx be used instead of tabular?
false
Defined in: src/lib/types.ts:133
string
The title of the document
If this is not set, the title will be taken from the heading with the "Title" style.
undefined
Defined in: src/lib/types.ts:120
number
What the top section should be -1 = part 0 = chapter 1 = section 2 = subsection 3 = subsubsection 4 = paragraph 5 = subparagraph
Defined in: src/lib/types.ts:40
boolean
Are you using xcolor?
Disabling this will remove the xcolor
package from the preamble
and remove color related commands from the output.
true
Defined in: src/lib/types.ts:112
HWithProps
&HWithoutProps
&Context
Defined in: src/lib/types.ts:292
Function
(h: H, node: any, parent?: Parent): UnifiedLatexNode | UnifiedLatexNode[] | void | undefined;
Name | Type |
---|---|
h |
H |
node |
any |
parent? |
Parent |
UnifiedLatexNode
| UnifiedLatexNode
[] | void
| undefined
Defined in: src/lib/types.ts:196
Root
|String
|Whitespace
|Parbreak
|Comment
|Macro
|Environment
|VerbatimEnvironment
|InlineMath
|DisplayMath
|Group
|Verb
Defined in: node_modules/.pnpm/@[email protected]/node_modules/@unified-latex/unified-latex-types/libs/ast-types.d.ts:83
GPL-3.0-or-later © Thomas F. K. Jorna