Skip to content

Commit 6d0184e

Browse files
vladislavkeblyshihor-romaniuk
authored andcommitted
feat: mathjax for formules formatting
1 parent fb06133 commit 6d0184e

File tree

5 files changed

+40
-27
lines changed

5 files changed

+40
-27
lines changed

.eslintrc.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ const config = createConfig('eslint', {
77
'import/no-named-as-default-member': 'off',
88
'import/no-import-module-exports': 'off',
99
'import/no-self-import': 'off',
10-
'spaced-comment': ['error', 'always', { 'block': { 'exceptions': ['*'] } }],
10+
'spaced-comment': ['error', 'always', { block: { exceptions: ['*'] } }],
1111
'react-hooks/rules-of-hooks': 'off',
12-
"react/forbid-prop-types": ["error", { "forbid": ["any", "array"] }], // arguable object proptype is use when I do not care about the shape of the object
12+
'react/forbid-prop-types': ['error', { forbid: ['any', 'array'] }], // arguable object proptype is use when I do not care about the shape of the object
1313
'no-import-assign': 'off',
1414
'no-promise-executor-return': 'off',
1515
'import/no-cycle': 'off',
1616
},
1717
});
1818

1919
config.settings = {
20-
"import/resolver": {
20+
'import/resolver': {
2121
node: {
22-
paths: ["src", "node_modules"],
23-
extensions: [".js", ".jsx"],
22+
paths: ['src', 'node_modules'],
23+
extensions: ['.js', '.jsx'],
2424
},
2525
},
2626
};

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"@testing-library/user-event": "^14.0.0",
4444
"@zip.js/zip.js": "^2.4.6",
4545
"axios": "^0.28.0",
46+
"better-react-mathjax": "^2.0.3",
4647
"classnames": "^2.3.1",
4748
"core-js": "3.35.1",
4849
"dompurify": "^2.3.1",

src/App.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { selectors } from 'data/redux';
1111
import DemoWarning from 'containers/DemoWarning';
1212
import NotificationsBanner from 'containers/NotificationsBanner';
1313
import ListView from 'containers/ListView';
14+
import { MathJaxContext } from 'better-react-mathjax';
1415

1516
import './App.scss';
1617
import Head from './components/Head';
@@ -28,7 +29,9 @@ export const App = ({ courseMetadata, isEnabled }) => (
2829
{!isEnabled && <DemoWarning />}
2930
<NotificationsBanner />
3031
<main data-testid="main">
31-
<ListView />
32+
<MathJaxContext>
33+
<ListView />
34+
</MathJaxContext>
3235
</main>
3336
<FooterSlot />
3437
</div>

src/containers/ResponseDisplay/__snapshots__/index.test.jsx.snap

+22-18
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ exports[`ResponseDisplay component snapshot file upload disable with valid respo
44
<div
55
className="response-display"
66
>
7-
<Card
8-
key="0"
9-
>
10-
<Card.Section
11-
className="response-display-text-content"
12-
data-testid="response-display-text-content"
7+
<MathJax>
8+
<Card
9+
key="0"
1310
>
14-
parsed html (sanitized (some text response here))
15-
</Card.Section>
16-
</Card>
11+
<Card.Section
12+
className="response-display-text-content"
13+
data-testid="response-display-text-content"
14+
>
15+
parsed html (sanitized (some text response here))
16+
</Card.Section>
17+
</Card>
18+
</MathJax>
1719
</div>
1820
`;
1921

@@ -70,16 +72,18 @@ exports[`ResponseDisplay component snapshot file upload enable with valid respon
7072
]
7173
}
7274
/>
73-
<Card
74-
key="0"
75-
>
76-
<Card.Section
77-
className="response-display-text-content"
78-
data-testid="response-display-text-content"
75+
<MathJax>
76+
<Card
77+
key="0"
7978
>
80-
parsed html (sanitized (some text response here))
81-
</Card.Section>
82-
</Card>
79+
<Card.Section
80+
className="response-display-text-content"
81+
data-testid="response-display-text-content"
82+
>
83+
parsed html (sanitized (some text response here))
84+
</Card.Section>
85+
</Card>
86+
</MathJax>
8387
</div>
8488
`;
8589

src/containers/ResponseDisplay/index.jsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
4+
import { MathJax } from 'better-react-mathjax';
45

56
import { Card } from '@openedx/paragon';
67

@@ -47,9 +48,13 @@ export class ResponseDisplay extends React.Component {
4748
{
4849
/* eslint-disable react/no-array-index-key */
4950
this.textContents.map((textContent, index) => (
50-
<Card key={index}>
51-
<Card.Section className="response-display-text-content" data-testid="response-display-text-content">{textContent}</Card.Section>
52-
</Card>
51+
<MathJax>
52+
<Card key={index}>
53+
<Card.Section className="response-display-text-content" data-testid="response-display-text-content">
54+
{textContent}
55+
</Card.Section>
56+
</Card>
57+
</MathJax>
5358
))
5459
}
5560
</div>

0 commit comments

Comments
 (0)