diff --git a/testsuite/tests/input/tex/ConfigMacros.test.ts b/testsuite/tests/input/tex/ConfigMacros.test.ts
index 74a0c863c4..cd906b4ba9 100644
--- a/testsuite/tests/input/tex/ConfigMacros.test.ts
+++ b/testsuite/tests/input/tex/ConfigMacros.test.ts
@@ -4,13 +4,11 @@ import '#js/input/tex/configmacros/ConfigMacrosConfiguration.js';
beforeEach(() => {});
-function runMacroTests(
+function runMacroTest(
macros: { [key: string]: any },
- control: string,
macro: string
) {
setupTex(['base', 'configmacros'], macros);
- expect(tex2mml(control)).toMatchSnapshot();
expect(tex2mml(macro)).toMatchSnapshot();
}
@@ -18,7 +16,7 @@ function runMacroTests(
describe('Config Macros Active', () => {
it('Macros Simple', () => {
- runMacroTests({ active: { '@': '~' } }, 'A~a', 'A@a');
+ runMacroTest({ active: { '@': '~' } }, 'A@a');
});
});
@@ -26,37 +24,42 @@ describe('Config Macros Active', () => {
describe('Config Macros Commands', () => {
it('Commands Simple', () => {
- runMacroTests({ macros: { RR: '{\\bf R}' } }, '{\\bf R}', '\\RR');
+ runMacroTest({ macros: { RR: '{\\bf R}' } }, '\\RR');
});
it('Commands Argument', () => {
- runMacroTests(
- { macros: { bold: ['{\\bf #1}', 1] } },
- '{\\bf bold}',
- '\\bold{bold}'
- );
+ runMacroTest({ macros: { bold: ['{\\bf #1}', 1] } }, '\\bold{bold}');
});
it('Commands Aux Argument', () => {
- runMacroTests(
+ runMacroTest(
{
macros: {
foo: ['\\mbox{first } #1 \\mbox{ second } #2', 2, ['[', ']']],
},
},
- '\\mbox{first } hi \\mbox{ second } there',
'\\foo[hi]{there}'
);
});
+
+ it('Commands Template', () => {
+ runMacroTest(
+ {
+ macros: {
+ foo: ['\\text{[#1]}', 1, [undefined , '+ \\oof']]
+ }
+ },
+ '\\foo A + \\oof'
+ );
+ });
});
/**********************************************************************************/
describe('Config Macros Environment', () => {
it('Environment Simple', () => {
- runMacroTests(
+ runMacroTest(
{ environments: { myHeartEnv: ['\\heartsuit', '\\spadesuit'] } },
- '\\begin{myHeartEnv}a\\end{myHeartEnv}',
'\\begin{myHeartEnv}a\\end{myHeartEnv}'
);
});
diff --git a/testsuite/tests/input/tex/Newcommand.test.ts b/testsuite/tests/input/tex/Newcommand.test.ts
index 06dee75bfe..f252ce4034 100644
--- a/testsuite/tests/input/tex/Newcommand.test.ts
+++ b/testsuite/tests/input/tex/Newcommand.test.ts
@@ -244,10 +244,76 @@ describe('Newcommand', () => {
expectTexError('\\def\\x#1 #2 {[#1,#2]} \\x{a}{b}').toBe(
'Runaway argument for \\x?'
);
- expectTexError('\\def\\x#1 #2 {[#1,#2]} \\x{a} {b}').toBe(
- 'Runaway argument for \\x?'
- );
- expect(tex2mml('\\def\\x#1 #2{[#1,#2]} \\x{a} {b} ')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x#1 #2 {[#1,#2]} \\x{a} {b}')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x#1 #2 {[#1,#2]} \\x{a} {b} ')).toMatchSnapshot();
+ });
+
+ it('Def braces', () => {
+ expect(tex2mml('\\def\\x #1\\a{x^#1}\\x {23}\\a')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\\a{x^#1}\\x {23} \\a')).toMatchSnapshot();
+ });
+
+ it('Def newlines, spaces, tabs', () => {
+ expect(tex2mml('\\def\\x #1\n#2{\\text{[#1][#2]}}\\x a\nb')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\n#2{\\text{[#1][#2]}}\\x a b')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\n#2{\\text{[#1][#2]}}\\x a\tb')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\n#2{\\text{[#1][#2]}}\\x a\t \nb')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1 #2{\\text{[#1][#2]}}\\x a\nb')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1 #2{\\text{[#1][#2]}}\\x a b')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1 #2{\\text{[#1][#2]}}\\x a\tb')).toMatchSnapshot();
+ });
+
+ it('Def multiple spaces', () => {
+ expect(tex2mml('\\def\\x #1 #2{\\text{[#1][#2]}}\\x a b')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1 #2{\\text{[#1][#2]}}\\x a b')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\\a\\b#2\\c{\\text{[#1][#2]}}\\x a\\a\\b b\\c')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\\a\\b#2\\c{\\text{[#1][#2]}}\\x a\\a \\b b \\c')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\\a\\b#2\\c{\\text{[#1][#2]}}\\x a\\a \\b b \\c')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\\a b{\\text{[#1]}}\\x a\\a b')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\\a b{\\text{[#1]}}\\x a\\a\n b')).toMatchSnapshot();
+ });
+
+ it('Def multiple arg template', () => {
+ expect(tex2mml('\\def\\x #1#2\\x{\\text{[#1][#2]}}\\x abc\\x')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1#2\\x{\\text{[#1][#2]}}\\x {abc}\\x')).toMatchSnapshot();
+ });
+
+ it('Def partial template match', () => {
+ expect(tex2mml('\\def\\x #1ab{\\text{[#1]}}\\x axab')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1ab{\\text{[#1]}}\\x ax a b cab')).toMatchSnapshot();
+ });
+
+ it('Def empty template arg', () => {
+ expect(tex2mml('\\def\\x #1ab{\\text{[#1]}}\\x ab')).toMatchSnapshot();
+ });
+
+ it('Def comments', () => {
+ expect(tex2mml('\\def\\x #1{\\text{[#1]}}\\x%{}\n{ab}')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\\a{\\text{[#1]}}\\x ab%{}\ncd\\a')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1%{\n#2{\\text{[#1][#2]}}\\x ab')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1\\a#2\\b{\\text{[#1][#2]}}\\x %\\a\n a\\a %\\b\n b\\b')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x #1{%x}\n\\text{[#1]}}\\x a')).toMatchSnapshot();
+ expectTexError('\\def\\x{\\text{%}}\\x').toBe('Missing close brace');
+ expectTexError('\\def\\x #1X{\\text{[#1]}}\\x%aX').toBe('Runaway argument for \\x?');
+ });
+});
+
+/**********************************************************************************/
+
+describe('Newcommand legacy', () => {
+ beforeEach(() => setupTex(['base', 'newcommand'], {legacyComments: true, legacyMacroTemplates: true}));
+
+ it('Def legacy comments', () => {
+ expect(tex2mml('\\def\\x #1%X{\\text{[#1]}}\\x a%X')).toMatchSnapshot();
+ expect(tex2mml('\\def\\x{\\text{%}}\\x')).toMatchSnapshot();
+ });
+
+ it('Def legacy macro templates', () => {
+ expectTexError('\\def\\x #1X Y{\\text{[#1]}}\\x aX Y').toBe('Runaway argument for \\x?');
+ expect(tex2mml('\\def\\x #1X Y{\\text{[#1]}}\\x aX Y')).toMatchSnapshot();
+ expectTexError('\\def\\x #1X\nY{\\text{[#1]}}\\x aX Y').toBe('Runaway argument for \\x?');
+ expectTexError('\\def\\x #1X\nY{\\text{[#1]}}\\x aX \nY').toBe('Runaway argument for \\x?');
+ expect(tex2mml('\\def\\x #1X\nY{\\text{[#1]}}\\x aX\nY')).toMatchSnapshot();
});
});
diff --git a/testsuite/tests/input/tex/Verb.test.ts b/testsuite/tests/input/tex/Verb.test.ts
index 04cfd897d6..1ed1f1067d 100644
--- a/testsuite/tests/input/tex/Verb.test.ts
+++ b/testsuite/tests/input/tex/Verb.test.ts
@@ -7,7 +7,7 @@ beforeEach(async () => setupTex(['base', 'verb']));
/**********************************************************************************/
describe('Verb', () => {
- it('Verb Plus ', () => {
+ it('Verb Plus', () => {
expect(tex2mml('\\verb+{a}+')).toMatchSnapshot();
});
diff --git a/testsuite/tests/input/tex/__snapshots__/ConfigMacros.test.ts.snap b/testsuite/tests/input/tex/__snapshots__/ConfigMacros.test.ts.snap
index 2520af2915..aa49de38e3 100644
--- a/testsuite/tests/input/tex/__snapshots__/ConfigMacros.test.ts.snap
+++ b/testsuite/tests/input/tex/__snapshots__/ConfigMacros.test.ts.snap
@@ -1,14 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Config Macros Active Macros Simple 1`] = `
-""
-`;
-
-exports[`Config Macros Active Macros Simple 2`] = `
"