Skip to content

Commit 1b1c545

Browse files
feat(math-rendering): add abs macro support in TeX configuration PIE-442
1 parent 0f9838f commit 1b1c545

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

packages/math-rendering/src/__tests__/render-math.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { render } from '@testing-library/react';
3+
import { TeX } from 'mathjax-full/js/input/tex';
34
import renderMath, { fixMathElement } from '../render-math';
45
import { times } from 'lodash-es';
56

@@ -140,6 +141,16 @@ describe('render-math', () => {
140141
});
141142
});
142143

144+
it('registers the abs macro in the TeX config', () => {
145+
const div = document.createElement('div');
146+
147+
renderMath(div);
148+
149+
const texConfig = TeX.mock.calls[0][0];
150+
151+
expect(texConfig.macros.abs).toEqual(['\\left|#1\\right|', 1]);
152+
});
153+
143154
it('wraps the math containing element the right way', () => {
144155
const { container } = render(
145156
<div>

packages/math-rendering/src/render-math.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ const createMathMLInstance = (opts, docProvided = document) => {
132132
overarc: '\\overparen',
133133
napprox: '\\not\\approx',
134134
longdiv: '\\enclose{longdiv}',
135+
abs: ['\\left|#1\\right|', 1],
135136
};
136137

137138
const texConfig = opts.useSingleDollar

0 commit comments

Comments
 (0)