Skip to content

Commit

Permalink
feat: mathjax for formules formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vladislavkeblysh committed Jun 13, 2024
1 parent 64b57df commit 3612fe9
Show file tree
Hide file tree
Showing 7 changed files with 1,954 additions and 1,038 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ const config = createConfig('eslint', {
'import/no-named-as-default-member': 'off',
'import/no-import-module-exports': 'off',
'import/no-self-import': 'off',
'spaced-comment': ['error', 'always', { 'block': { 'exceptions': ['*'] } }],
'spaced-comment': ['error', 'always', { block: { exceptions: ['*'] } }],
'react-hooks/rules-of-hooks': 'off',
"react/forbid-prop-types": ["error", { "forbid": ["any", "array"] }], // arguable object proptype is use when I do not care about the shape of the object
'react/forbid-prop-types': ['error', { forbid: ['any', 'array'] }], // arguable object proptype is use when I do not care about the shape of the object
'no-import-assign': 'off',
'no-promise-executor-return': 'off',
'import/no-cycle': 'off',
},
});

config.settings = {
"import/resolver": {
'import/resolver': {
node: {
paths: ["src", "node_modules"],
extensions: [".js", ".jsx"],
paths: ['src', 'node_modules'],
extensions: ['.js', '.jsx'],
},
},
};
Expand Down
2,843 changes: 1,871 additions & 972 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@testing-library/user-event": "^14.0.0",
"@zip.js/zip.js": "^2.4.6",
"axios": "^0.28.0",
"better-react-mathjax": "^2.0.3",
"classnames": "^2.3.1",
"core-js": "3.35.1",
"dompurify": "^2.3.1",
Expand Down
5 changes: 4 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import DemoWarning from 'containers/DemoWarning';
import CTA from 'containers/CTA';
import NotificationsBanner from 'containers/NotificationsBanner';
import ListView from 'containers/ListView';
import { MathJaxContext } from 'better-react-mathjax';

import './App.scss';
import Head from './components/Head';
Expand All @@ -30,7 +31,9 @@ export const App = ({ courseMetadata, isEnabled }) => (
<CTA />
<NotificationsBanner />
<main data-testid="main">
<ListView />
<MathJaxContext>
<ListView />
</MathJaxContext>
</main>
<FooterSlot />
</div>
Expand Down
82 changes: 43 additions & 39 deletions src/__snapshots__/App.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`App router component snapshot: disabled (show demo warning) 1`] = `
<BrowserRouter>
<div>
<Head />
<Header
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<DemoWarning />
<CTA />
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<FooterSlot />
</div>
</BrowserRouter>
<MathJaxContext>
<BrowserRouter>
<div>
<Head />
<Header
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<DemoWarning />
<CTA />
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<FooterSlot />
</div>
</BrowserRouter>
</MathJaxContext>
`;

exports[`App router component snapshot: enabled 1`] = `
<BrowserRouter>
<div>
<Head />
<Header
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<CTA />
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<FooterSlot />
</div>
</BrowserRouter>
<MathJaxContext>
<BrowserRouter>
<div>
<Head />
<Header
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<CTA />
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<FooterSlot />
</div>
</BrowserRouter>
</MathJaxContext>
`;
40 changes: 22 additions & 18 deletions src/containers/ResponseDisplay/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ exports[`ResponseDisplay component snapshot file upload disable with valid respo
<div
className="response-display"
>
<Card
key="0"
>
<Card.Section
className="response-display-text-content"
data-testid="response-display-text-content"
<MathJax>
<Card
key="0"
>
parsed html (sanitized (some text response here))
</Card.Section>
</Card>
<Card.Section
className="response-display-text-content"
data-testid="response-display-text-content"
>
parsed html (sanitized (some text response here))
</Card.Section>
</Card>
</MathJax>
</div>
`;

Expand Down Expand Up @@ -70,16 +72,18 @@ exports[`ResponseDisplay component snapshot file upload enable with valid respon
]
}
/>
<Card
key="0"
>
<Card.Section
className="response-display-text-content"
data-testid="response-display-text-content"
<MathJax>
<Card
key="0"
>
parsed html (sanitized (some text response here))
</Card.Section>
</Card>
<Card.Section
className="response-display-text-content"
data-testid="response-display-text-content"
>
parsed html (sanitized (some text response here))
</Card.Section>
</Card>
</MathJax>
</div>
`;

Expand Down
11 changes: 8 additions & 3 deletions src/containers/ResponseDisplay/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { MathJax } from 'better-react-mathjax';

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

Expand Down Expand Up @@ -47,9 +48,13 @@ export class ResponseDisplay extends React.Component {
{
/* eslint-disable react/no-array-index-key */
this.textContents.map((textContent, index) => (
<Card key={index}>
<Card.Section className="response-display-text-content" data-testid="response-display-text-content">{textContent}</Card.Section>
</Card>
<MathJax>
<Card key={index}>
<Card.Section className="response-display-text-content" data-testid="response-display-text-content">
{textContent}
</Card.Section>
</Card>
</MathJax>
))
}
</div>
Expand Down

0 comments on commit 3612fe9

Please sign in to comment.