-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove 'katex' from @khanacademy/perseus #1428
Changes from 4 commits
436ff5a
173bc5c
b41157d
30a15d3
d3830e8
cb6866c
88c2141
0e398f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
--- | ||
|
||
Drop katex dependency - no longer used |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -519,9 +519,9 @@ | |
* Displays a tooltip above the point, replacing any previous contents. If | ||
* there is no tooltip initialized, adds the tooltip. | ||
* | ||
* If the type of contents is string, the contents will be rendered with | ||
* KaTeX. Otherwise, the content will be assumed to be a DOM node and will | ||
* be appended inside the tooltip. | ||
* If the type of contents is string, the contents will be rendered as TeX | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: TeX is the input language, so I think it would be more accurate to say that "the contents will be interpreted as TeX and rendered as DOM elements" |
||
* Otherwise, the content will be assumed to be a DOM node and will be | ||
* appended inside the tooltip. | ||
*/ | ||
_showTooltip(contents) { | ||
if (!this._tooltip) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ import PerseusMarkdown from "./perseus-markdown"; | |
import QuestionParagraph from "./question-paragraph"; | ||
import TranslationLinter from "./translation-linter"; | ||
import Util from "./util"; | ||
import preprocessTex from "./util/katex-preprocess"; | ||
import preprocessTex from "./util/tex-preprocess"; | ||
import WidgetContainer from "./widget-container"; | ||
import * as Widgets from "./widgets"; | ||
|
||
|
@@ -1289,12 +1289,6 @@ class Renderer extends React.Component<Props, State> { | |
); | ||
} | ||
if (node.type === "math") { | ||
// Replace uses of \begin{align}...\end{align} which KaTeX doesn't | ||
// support (yet) with \begin{aligned}...\end{aligned} which renders | ||
// the same is supported by KaTeX. It does the same for align*. | ||
// TODO(kevinb) update content to use aligned instead of align. | ||
const tex = node.content.replace(/\{align[*]?\}/g, "{aligned}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MathJax supports the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this code might break the exercise editor, which still uses KaTeX behind the scenes to validate that the input TeX can render with KaTeX. This gets complicated to reason about, because the reason the editor does that is to ensure that TeX written by content creators is compatible with old versions of the mobile app, which use KaTeX (and old versions of Perseus which have this replacement logic, so I think we could move this logic to the exercise editor and it would be fine. But I'd lean toward keeping this code the same until we can remove KaTeX everywhere. If you agree, can you restore this code and add a TODO comment here referencing LEMS-1608? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, I looked up our new mobile deprecation policy and I believe we will be able to completely remove KaTeX starting September 18th! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to move forward and land this, so I'll do as Ben suggests and restore this code with a new TODO. Thanks for thinking of that Ben! |
||
|
||
// We render math here instead of in perseus-markdown.jsx | ||
// because we need to pass it our onRender callback. | ||
return ( | ||
|
@@ -1316,7 +1310,7 @@ class Renderer extends React.Component<Props, State> { | |
onRender={this.props.onRender} | ||
setAssetStatus={setAssetStatus} | ||
> | ||
{tex} | ||
{node.content} | ||
</TeX> | ||
)} | ||
</AssetContext.Consumer> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,7 +318,6 @@ export type APIOptions = Readonly<{ | |
|
||
type TeXProps = { | ||
children: string; | ||
katexOptions?: any; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked and this prop/string is not used in webapp anywhere! |
||
onClick?: () => unknown; | ||
onRender?: (root?: any) => unknown; | ||
style?: any; | ||
|
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Git(hub) doesn't seem to recognize that this is a rename. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Preprocess TeX code to convert things that MathJax doesn't know how to handle | ||
* to things is does. | ||
*/ | ||
export default (texCode: string): string => | ||
texCode | ||
// Replace non-breaking spaces with regular spaces. | ||
.replace(/[\u00a0]/g, " "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't even make sense of what was to be done here so I'm deleting this comment.