vault backup: 2025-04-10 14:02:57
This commit is contained in:
38
.obsidian/plugins/obsidian-enhancing-export-main/tests/common.ts
vendored
Normal file
38
.obsidian/plugins/obsidian-enhancing-export-main/tests/common.ts
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
import os from 'os';
|
||||
import { exec as execSync, ExecException } from 'child_process';
|
||||
import { readFile } from 'fs/promises';
|
||||
|
||||
|
||||
export async function exec(cmd: string, options: { lineSeparator: '\n' | '\r\n' | '\r' }): Promise<string> {
|
||||
function lineSeparator(s?: string, ls?: '\n' | '\r\n' | '\r') {
|
||||
if (!s || os.EOL === ls || !ls) {
|
||||
return s;
|
||||
}
|
||||
return s.replaceAll(os.EOL, ls);
|
||||
}
|
||||
return await new Promise((resolve, reject) => {
|
||||
execSync(cmd, { encoding: 'utf-8', cwd: module.path }, (e: ExecException, stdout: string, stderr: string) => {
|
||||
if (!e) {
|
||||
resolve(lineSeparator(stdout, options?.lineSeparator));
|
||||
} else {
|
||||
reject(lineSeparator(stderr, options?.lineSeparator));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export const testConversion = async (name: string, filter?: string) => {
|
||||
process.chdir(module.path);
|
||||
const input_file = `./markdowns/${name}.md`;
|
||||
const expect_out = `./markdowns/${name}.out`;
|
||||
let pandoc: string;
|
||||
if (filter) {
|
||||
const lua_script = `../lua/${filter}.lua`;
|
||||
pandoc = `pandoc -s -L ${lua_script} -t native -f markdown "${input_file}" -o -`;
|
||||
} else {
|
||||
pandoc = `pandoc -s -t native -f markdown "${input_file}" -o -`;
|
||||
}
|
||||
const ret = await exec(pandoc, { lineSeparator: '\n'});
|
||||
expect(ret).toBe(await readFile(expect_out, { encoding: 'utf-8', flag: 'r' }));
|
||||
};
|
15
.obsidian/plugins/obsidian-enhancing-export-main/tests/internalLink.spec.ts
vendored
Normal file
15
.obsidian/plugins/obsidian-enhancing-export-main/tests/internalLink.spec.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
import { testConversion } from './common';
|
||||
|
||||
|
||||
test('test basic internal link block parsing', async () => {
|
||||
await testConversion('internal-link-basic', 'markdown');
|
||||
});
|
||||
|
||||
test('test complex internal link block parsing', async () => {
|
||||
await testConversion('internal-link-bullet', 'markdown');
|
||||
});
|
||||
|
||||
test('test basic internal link with description', async () => {
|
||||
await testConversion('internal-link-described', 'markdown');
|
||||
});
|
1
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-basic.md
vendored
Normal file
1
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-basic.md
vendored
Normal file
@ -0,0 +1 @@
|
||||
[[#Some complex section]]
|
14
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-basic.out
vendored
Normal file
14
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-basic.out
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
Pandoc
|
||||
Meta { unMeta = fromList [] }
|
||||
[ Para
|
||||
[ Link
|
||||
( "" , [] , [] )
|
||||
[ Str "Some"
|
||||
, Space
|
||||
, Str "complex"
|
||||
, Space
|
||||
, Str "section"
|
||||
]
|
||||
( "#Some-complex-section" , "" )
|
||||
]
|
||||
]
|
3
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-bullet.md
vendored
Normal file
3
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-bullet.md
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
- potato
|
||||
- [[#more complex vegetables]]
|
||||
- cucumber
|
19
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-bullet.out
vendored
Normal file
19
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-bullet.out
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Pandoc
|
||||
Meta { unMeta = fromList [] }
|
||||
[ BulletList
|
||||
[ [ Plain [ Str "potato" ] ]
|
||||
, [ Plain
|
||||
[ Link
|
||||
( "" , [] , [] )
|
||||
[ Str "more"
|
||||
, Space
|
||||
, Str "complex"
|
||||
, Space
|
||||
, Str "vegetables"
|
||||
]
|
||||
( "#more-complex-vegetables" , "" )
|
||||
]
|
||||
]
|
||||
, [ Plain [ Str "cucumber" ] ]
|
||||
]
|
||||
]
|
1
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-described.md
vendored
Normal file
1
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-described.md
vendored
Normal file
@ -0,0 +1 @@
|
||||
[[#Some complex section|with custom description]]
|
14
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-described.out
vendored
Normal file
14
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/internal-link-described.out
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
Pandoc
|
||||
Meta { unMeta = fromList [] }
|
||||
[ Para
|
||||
[ Link
|
||||
( "" , [] , [] )
|
||||
[ Str "with"
|
||||
, Space
|
||||
, Str "custom"
|
||||
, Space
|
||||
, Str "description"
|
||||
]
|
||||
( "#Some-complex-section" , "" )
|
||||
]
|
||||
]
|
41
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block-01-no-empty-lines.md
vendored
Normal file
41
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block-01-no-empty-lines.md
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
$$
|
||||
\left(\begin{array}{c}
|
||||
\hat{F}_{1,i,j}\\ \hat{F}_{2,i,j} \\ \vdots \\ \hat{F}_{C-1,i,j} \\ \hat{F}_{C,i,j}
|
||||
\end{array}\right)
|
||||
=
|
||||
\begin{pmatrix}
|
||||
\frac{\gamma_1}{\sqrt{\hat{\sigma}^2_1}+\epsilon} & 0 & \cdots & &0
|
||||
\\
|
||||
0 && \frac{\gamma_2}{\sqrt{\hat{\sigma}^2_2}+\epsilon} & & & &
|
||||
\\
|
||||
\vdots && \ddots && \vdots
|
||||
\\
|
||||
&&& \frac{\gamma_{C-1}}{\sqrt{\hat{\sigma}^2_{C-1}+\epsilon}} & 0
|
||||
\\
|
||||
0 && \cdots &0 & \frac{\gamma_C}{\sqrt{\hat{\sigma}^2_{C}+\epsilon}}
|
||||
\end{pmatrix}
|
||||
\cdot
|
||||
\begin{pmatrix}
|
||||
F_{1,i,j}
|
||||
\\
|
||||
F_{2,i,j}
|
||||
\\
|
||||
\vdots
|
||||
\\
|
||||
F_{C-1,i,j}
|
||||
\\
|
||||
F_{C,i,j}
|
||||
\end{pmatrix}
|
||||
+
|
||||
\begin{pmatrix}
|
||||
\beta_1-\gamma_1\frac{\hat{\mu}_1}{\sqrt{\hat{\sigma}^2_1+\epsilon}}
|
||||
\\
|
||||
\beta_2-\gamma_2\frac{\hat{\mu}_2}{\sqrt{\hat{\sigma}^2_2+\epsilon}}
|
||||
\\
|
||||
\vdots
|
||||
\\
|
||||
\beta_{C-1}-\gamma_{C-1}\frac{\hat{\mu}_{C-1}}{\sqrt{\hat{\sigma}^2_{C-1}+\epsilon}}
|
||||
\\
|
||||
\beta_C-\gamma_C\frac{\hat{\mu}_C}{\sqrt{\hat{\sigma}^2_C+\epsilon}}
|
||||
\end{pmatrix}
|
||||
$$
|
@ -0,0 +1,8 @@
|
||||
Pandoc
|
||||
Meta { unMeta = fromList [] }
|
||||
[ Para
|
||||
[ Math
|
||||
DisplayMath
|
||||
"\n\\left(\\begin{array}{c}\n\\hat{F}_{1,i,j}\\\\ \\hat{F}_{2,i,j} \\\\ \\vdots \\\\ \\hat{F}_{C-1,i,j} \\\\ \\hat{F}_{C,i,j}\n\\end{array}\\right)\n=\n\\begin{pmatrix}\n\\frac{\\gamma_1}{\\sqrt{\\hat{\\sigma}^2_1}+\\epsilon} & 0 & \\cdots & &0\n\\\\\n0 && \\frac{\\gamma_2}{\\sqrt{\\hat{\\sigma}^2_2}+\\epsilon} & & & &\n\\\\\n\\vdots && \\ddots && \\vdots\n\\\\\n&&& \\frac{\\gamma_{C-1}}{\\sqrt{\\hat{\\sigma}^2_{C-1}+\\epsilon}} & 0\n\\\\\n0 && \\cdots &0 & \\frac{\\gamma_C}{\\sqrt{\\hat{\\sigma}^2_{C}+\\epsilon}}\n\\end{pmatrix}\n\\cdot\n\\begin{pmatrix}\nF_{1,i,j}\n\\\\\nF_{2,i,j}\n\\\\\n\\vdots\n\\\\\nF_{C-1,i,j}\n\\\\\nF_{C,i,j}\n\\end{pmatrix}\n+\n\\begin{pmatrix}\n\\beta_1-\\gamma_1\\frac{\\hat{\\mu}_1}{\\sqrt{\\hat{\\sigma}^2_1+\\epsilon}}\n\\\\\n\\beta_2-\\gamma_2\\frac{\\hat{\\mu}_2}{\\sqrt{\\hat{\\sigma}^2_2+\\epsilon}}\n\\\\\n\\vdots\n\\\\\n\\beta_{C-1}-\\gamma_{C-1}\\frac{\\hat{\\mu}_{C-1}}{\\sqrt{\\hat{\\sigma}^2_{C-1}+\\epsilon}}\n\\\\\n\\beta_C-\\gamma_C\\frac{\\hat{\\mu}_C}{\\sqrt{\\hat{\\sigma}^2_C+\\epsilon}}\n\\end{pmatrix} \n"
|
||||
]
|
||||
]
|
51
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block-01.md
vendored
Normal file
51
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block-01.md
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
$$
|
||||
\left(\begin{array}{c}
|
||||
\hat{F}_{1,i,j}\\ \hat{F}_{2,i,j} \\ \vdots \\ \hat{F}_{C-1,i,j} \\ \hat{F}_{C,i,j}
|
||||
\end{array}\right)
|
||||
|
||||
=
|
||||
|
||||
\begin{pmatrix}
|
||||
\frac{\gamma_1}{\sqrt{\hat{\sigma}^2_1}+\epsilon} & 0 & \cdots & &0
|
||||
\\
|
||||
0 && \frac{\gamma_2}{\sqrt{\hat{\sigma}^2_2}+\epsilon} & & & &
|
||||
\\
|
||||
\vdots && \ddots && \vdots
|
||||
\\
|
||||
&&& \frac{\gamma_{C-1}}{\sqrt{\hat{\sigma}^2_{C-1}+\epsilon}} & 0
|
||||
\\
|
||||
0 && \cdots &0 & \frac{\gamma_C}{\sqrt{\hat{\sigma}^2_{C}+\epsilon}}
|
||||
|
||||
\end{pmatrix}
|
||||
|
||||
|
||||
\cdot
|
||||
|
||||
\begin{pmatrix}
|
||||
F_{1,i,j}
|
||||
\\
|
||||
F_{2,i,j}
|
||||
\\
|
||||
\vdots
|
||||
\\
|
||||
F_{C-1,i,j}
|
||||
\\
|
||||
|
||||
F_{C,i,j}
|
||||
\end{pmatrix}
|
||||
|
||||
+
|
||||
|
||||
\begin{pmatrix}
|
||||
\beta_1-\gamma_1\frac{\hat{\mu}_1}{\sqrt{\hat{\sigma}^2_1+\epsilon}}
|
||||
\\
|
||||
\beta_2-\gamma_2\frac{\hat{\mu}_2}{\sqrt{\hat{\sigma}^2_2+\epsilon}}
|
||||
\\
|
||||
\vdots
|
||||
\\
|
||||
\beta_{C-1}-\gamma_{C-1}\frac{\hat{\mu}_{C-1}}{\sqrt{\hat{\sigma}^2_{C-1}+\epsilon}}
|
||||
\\
|
||||
\beta_C-\gamma_C\frac{\hat{\mu}_C}{\sqrt{\hat{\sigma}^2_C+\epsilon}}
|
||||
|
||||
\end{pmatrix}
|
||||
$$
|
28
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block-01.orig
vendored
Normal file
28
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block-01.orig
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
Pandoc
|
||||
Meta { unMeta = fromList [] }
|
||||
[ Plain
|
||||
[ Str "$$"
|
||||
, SoftBreak
|
||||
, RawInline (Format "tex") "\\left"
|
||||
, Str "("
|
||||
]
|
||||
, RawBlock
|
||||
(Format "tex")
|
||||
"\\begin{array}{c}\n\\hat{F}_{1,i,j}\\\\ \\hat{F}_{2,i,j} \\\\ \\vdots \\\\ \\hat{F}_{C-1,i,j} \\\\ \\hat{F}_{C,i,j}\n\\end{array}"
|
||||
, Header
|
||||
1
|
||||
( "section" , [] , [] )
|
||||
[ RawInline (Format "tex") "\\right" , Str ")" ]
|
||||
, RawBlock
|
||||
(Format "tex")
|
||||
"\\begin{pmatrix}\n\\frac{\\gamma_1}{\\sqrt{\\hat{\\sigma}^2_1}+\\epsilon} & 0 & \\cdots & &0\n\\\\\n0 && \\frac{\\gamma_2}{\\sqrt{\\hat{\\sigma}^2_2}+\\epsilon} & & & &\n\\\\\n\\vdots && \\ddots && \\vdots\n\\\\\n&&& \\frac{\\gamma_{C-1}}{\\sqrt{\\hat{\\sigma}^2_{C-1}+\\epsilon}} & 0\n\\\\\n0 && \\cdots &0 & \\frac{\\gamma_C}{\\sqrt{\\hat{\\sigma}^2_{C}+\\epsilon}}\n\n\\end{pmatrix}"
|
||||
, RawBlock (Format "tex") "\\cdot"
|
||||
, RawBlock
|
||||
(Format "tex")
|
||||
"\\begin{pmatrix}\nF_{1,i,j}\n\\\\\nF_{2,i,j}\n\\\\\n\\vdots\n\\\\\nF_{C-1,i,j}\n\\\\\n\nF_{C,i,j}\n\\end{pmatrix}"
|
||||
, BulletList [ [] ]
|
||||
, RawBlock
|
||||
(Format "tex")
|
||||
"\\begin{pmatrix}\n\\beta_1-\\gamma_1\\frac{\\hat{\\mu}_1}{\\sqrt{\\hat{\\sigma}^2_1+\\epsilon}}\n\\\\\n\\beta_2-\\gamma_2\\frac{\\hat{\\mu}_2}{\\sqrt{\\hat{\\sigma}^2_2+\\epsilon}}\n\\\\\n\\vdots\n\\\\\n\\beta_{C-1}-\\gamma_{C-1}\\frac{\\hat{\\mu}_{C-1}}{\\sqrt{\\hat{\\sigma}^2_{C-1}+\\epsilon}}\n\\\\\n\\beta_C-\\gamma_C\\frac{\\hat{\\mu}_C}{\\sqrt{\\hat{\\sigma}^2_C+\\epsilon}}\n\n\\end{pmatrix}"
|
||||
, Para [ Str "$$" ]
|
||||
]
|
11
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block-01.out
vendored
Normal file
11
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block-01.out
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
Pandoc
|
||||
Meta { unMeta = fromList [] }
|
||||
[ Plain []
|
||||
, Para []
|
||||
, Para []
|
||||
, Para
|
||||
[ Math
|
||||
DisplayMath
|
||||
"\n\\left(\\begin{array}{c}\n\\hat{F}_{1,i,j}\\\\ \\hat{F}_{2,i,j} \\\\ \\vdots \\\\ \\hat{F}_{C-1,i,j} \\\\ \\hat{F}_{C,i,j}\n\\end{array}\\right)=\\begin{pmatrix}\n\\frac{\\gamma_1}{\\sqrt{\\hat{\\sigma}^2_1}+\\epsilon} & 0 & \\cdots & &0\n\\\\\n0 && \\frac{\\gamma_2}{\\sqrt{\\hat{\\sigma}^2_2}+\\epsilon} & & & &\n\\\\\n\\vdots && \\ddots && \\vdots\n\\\\\n&&& \\frac{\\gamma_{C-1}}{\\sqrt{\\hat{\\sigma}^2_{C-1}+\\epsilon}} & 0\n\\\\\n0 && \\cdots &0 & \\frac{\\gamma_C}{\\sqrt{\\hat{\\sigma}^2_{C}+\\epsilon}}\n\n\\end{pmatrix}\\cdot\\begin{pmatrix}\nF_{1,i,j}\n\\\\\nF_{2,i,j}\n\\\\\n\\vdots\n\\\\\nF_{C-1,i,j}\n\\\\\n\nF_{C,i,j}\n\\end{pmatrix}\\begin{pmatrix}\n\\beta_1-\\gamma_1\\frac{\\hat{\\mu}_1}{\\sqrt{\\hat{\\sigma}^2_1+\\epsilon}}\n\\\\\n\\beta_2-\\gamma_2\\frac{\\hat{\\mu}_2}{\\sqrt{\\hat{\\sigma}^2_2+\\epsilon}}\n\\\\\n\\vdots\n\\\\\n\\beta_{C-1}-\\gamma_{C-1}\\frac{\\hat{\\mu}_{C-1}}{\\sqrt{\\hat{\\sigma}^2_{C-1}+\\epsilon}}\n\\\\\n\\beta_C-\\gamma_C\\frac{\\hat{\\mu}_C}{\\sqrt{\\hat{\\sigma}^2_C+\\epsilon}}\n\n\\end{pmatrix}\n"
|
||||
]
|
||||
]
|
13
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block.md
vendored
Normal file
13
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block.md
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
$$
|
||||
\begin{align*}
|
||||
\begin{rcases}
|
||||
\lambda_{1}(a_{11}^{*}, \ldots, a_{22}^{*}) < 0 \\
|
||||
\lambda_{2}(a_{11}^{*}, \ldots, a_{22}^{*}) < 0 \\
|
||||
\end{rcases} & \Rightarrow \text{stable knot} \\
|
||||
|
||||
\begin{rcases}
|
||||
\lambda_{1}(a_{11}^{*}, \ldots, a_{22}^{*}) > 0 \\
|
||||
\lambda_{2}(a_{11}^{*}, \ldots, a_{22}^{*}) < 0 \\
|
||||
\end{rcases} & \Rightarrow \text{saddle}
|
||||
\end{align*}
|
||||
$$
|
12
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block.orig
vendored
Normal file
12
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block.orig
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
Pandoc
|
||||
Meta { unMeta = fromList [] }
|
||||
[ Para
|
||||
[ Str "$$"
|
||||
, SoftBreak
|
||||
, RawInline
|
||||
(Format "tex")
|
||||
"\\begin{align*}\n\\begin{rcases}\n\\lambda_{1}(a_{11}^{*}, \\ldots, a_{22}^{*}) < 0 \\\\\n\\lambda_{2}(a_{11}^{*}, \\ldots, a_{22}^{*}) < 0 \\\\\n\\end{rcases} & \\Rightarrow \\text{stable knot} \\\\\n\n \\begin{rcases}\n \\lambda_{1}(a_{11}^{*}, \\ldots, a_{22}^{*}) > 0 \\\\\n \\lambda_{2}(a_{11}^{*}, \\ldots, a_{22}^{*}) < 0 \\\\\n \\end{rcases} & \\Rightarrow \\text{saddle}\n\\end{align*}"
|
||||
, SoftBreak
|
||||
, Str "$$"
|
||||
]
|
||||
]
|
8
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block.out
vendored
Normal file
8
.obsidian/plugins/obsidian-enhancing-export-main/tests/markdowns/math-block.out
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
Pandoc
|
||||
Meta { unMeta = fromList [] }
|
||||
[ Para
|
||||
[ Math
|
||||
DisplayMath
|
||||
"\n\\begin{align*}\n\\begin{rcases}\n\\lambda_{1}(a_{11}^{*}, \\ldots, a_{22}^{*}) < 0 \\\\\n\\lambda_{2}(a_{11}^{*}, \\ldots, a_{22}^{*}) < 0 \\\\\n\\end{rcases} & \\Rightarrow \\text{stable knot} \\\\\n\n \\begin{rcases}\n \\lambda_{1}(a_{11}^{*}, \\ldots, a_{22}^{*}) > 0 \\\\\n \\lambda_{2}(a_{11}^{*}, \\ldots, a_{22}^{*}) < 0 \\\\\n \\end{rcases} & \\Rightarrow \\text{saddle}\n\\end{align*}\n"
|
||||
]
|
||||
]
|
23
.obsidian/plugins/obsidian-enhancing-export-main/tests/mathBlock.spec.ts
vendored
Normal file
23
.obsidian/plugins/obsidian-enhancing-export-main/tests/mathBlock.spec.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import { testConversion } from './common';
|
||||
|
||||
|
||||
test('test math-block parsing', async () => {
|
||||
await testConversion('math-block', 'math_block');
|
||||
});
|
||||
|
||||
|
||||
test('test math-block-01 parsing', async () => {
|
||||
await testConversion('math-block-01', 'math_block');
|
||||
});
|
||||
|
||||
test('test math-block-01-no-empty-lines parsing', async () => {
|
||||
await testConversion('math-block-01-no-empty-lines', 'math_block');
|
||||
});
|
||||
|
||||
test('test math-block-01-no-empty-lines parsing filter off', async () => {
|
||||
await testConversion('math-block-01-no-empty-lines');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
7
.obsidian/plugins/obsidian-enhancing-export-main/tests/pandocVersion.spec.ts
vendored
Normal file
7
.obsidian/plugins/obsidian-enhancing-export-main/tests/pandocVersion.spec.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import pandoc from '../src/pandoc';
|
||||
|
||||
|
||||
test('test get pandoc version', async () => {
|
||||
const out = await pandoc.getVersion();
|
||||
expect(out.compare('3.1.5')).toBe(1);
|
||||
});
|
26
.obsidian/plugins/obsidian-enhancing-export-main/tests/platformValue.spec.ts
vendored
Normal file
26
.obsidian/plugins/obsidian-enhancing-export-main/tests/platformValue.spec.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
import { getPlatformValue, setPlatformValue } from '../src/utils';
|
||||
|
||||
|
||||
test('test get set platformValue 1', async () => {
|
||||
const val = setPlatformValue({}, 'abc');
|
||||
expect(getPlatformValue(val)).toBe('abc');
|
||||
});
|
||||
|
||||
test('test get set platformValue 2', async () => {
|
||||
const val = setPlatformValue({}, 'abc', '*');
|
||||
expect(getPlatformValue(val)).toBe('abc');
|
||||
});
|
||||
|
||||
test('test get set platformValue 3', async () => {
|
||||
let val = setPlatformValue<Record<string, string>>({}, { 'a': 'x' }, '*');
|
||||
val = setPlatformValue(val, { 'b': 'y' });
|
||||
expect(getPlatformValue(val)).toStrictEqual({ 'a': 'x', 'b': 'y' });
|
||||
});
|
||||
|
||||
test('test set platformValue on multi platform', async () => {
|
||||
const val = setPlatformValue<Record<string, string>>({}, { 'a': 'x' }, ['win32', 'darwin']);
|
||||
expect(val).toStrictEqual({
|
||||
'win32': { 'a': 'x' },
|
||||
'darwin': { 'a': 'x' }
|
||||
});
|
||||
});
|
32
.obsidian/plugins/obsidian-enhancing-export-main/tests/renderTemplate.spec.ts
vendored
Normal file
32
.obsidian/plugins/obsidian-enhancing-export-main/tests/renderTemplate.spec.ts
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
import { renderTemplate } from '../src/utils';
|
||||
|
||||
|
||||
test('test Template rendering', async () => {
|
||||
const out = renderTemplate('s${luaDir}e', { luaDir: 'w123' });
|
||||
expect(out).toBe('sw123e');
|
||||
});
|
||||
|
||||
test('test Template rendering 2', async () => {
|
||||
const out = renderTemplate('${HOME}', {
|
||||
'HOME': 'C:\\Users\\Admin',
|
||||
'CommonProgramFiles(x86)': 'C:\\Program Files (x86)\\Common Files',
|
||||
});
|
||||
expect(out).toBe('C:\\Users\\Admin');
|
||||
});
|
||||
|
||||
|
||||
test('test Template rendering options.textemplate', async () => {
|
||||
expect(renderTemplate('pandoc ${ options.textemplate ? `--template="${options.textemplate}"` : `` }',
|
||||
{ options: { textemplate: 'dissertation.tex' } }))
|
||||
.toBe('pandoc --template="dissertation.tex"');
|
||||
|
||||
expect(renderTemplate('pandoc ${ options.textemplate ? `--template="${options.textemplate}"` : `` }',
|
||||
{ options: { textemplate: null } }))
|
||||
.toBe('pandoc ');
|
||||
});
|
||||
|
||||
|
||||
test('test Template rendering with undefined variable', async () => {
|
||||
expect(renderTemplate('Hi ${user}', { }))
|
||||
.toBe('Hi ${user}');
|
||||
});
|
Reference in New Issue
Block a user