Skip to content
Snippets Groups Projects
Unverified Commit b4f80c3b authored by Timothy Carambat's avatar Timothy Carambat Committed by GitHub
Browse files

Add support for markdown/math equations (#2062)

parent 0141f91d
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"js-levenshtein": "^1.1.6", "js-levenshtein": "^1.1.6",
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"markdown-it": "^13.0.1", "markdown-it": "^13.0.1",
"markdown-it-katex": "^2.0.3",
"moment": "^2.30.1", "moment": "^2.30.1",
"pluralize": "^8.0.0", "pluralize": "^8.0.0",
"react": "^18.2.0", "react": "^18.2.0",
......
...@@ -794,3 +794,12 @@ does not extend the close button beyond the viewport. */ ...@@ -794,3 +794,12 @@ does not extend the close button beyond the viewport. */
top: -3.5rem; top: -3.5rem;
} }
} }
/* Math/Katex formatting to prevent duplication of content on screen */
.katex-html[aria-hidden="true"] {
display: none;
}
.katex-mathml {
font-size: 20px;
}
import { encode as HTMLEncode } from "he"; import { encode as HTMLEncode } from "he";
import markdownIt from "markdown-it"; import markdownIt from "markdown-it";
import markdownItKatex from "markdown-it-katex";
import hljs from "highlight.js"; import hljs from "highlight.js";
import "highlight.js/styles/github-dark-dimmed.min.css"; import "highlight.js/styles/github-dark-dimmed.min.css";
import { v4 } from "uuid"; import { v4 } from "uuid";
...@@ -43,7 +44,7 @@ const markdown = markdownIt({ ...@@ -43,7 +44,7 @@ const markdown = markdownIt({
"</pre></div>" "</pre></div>"
); );
}, },
}); }).use(markdownItKatex);
export default function renderMarkdown(text = "") { export default function renderMarkdown(text = "") {
return markdown.render(text); return markdown.render(text);
......
...@@ -2347,6 +2347,13 @@ json5@^2.2.3: ...@@ -2347,6 +2347,13 @@ json5@^2.2.3:
object.assign "^4.1.4" object.assign "^4.1.4"
object.values "^1.1.6" object.values "^1.1.6"
katex@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/katex/-/katex-0.6.0.tgz#12418e09121c05c92041b6b3b9fb6bab213cb6f3"
integrity sha512-rS4mY3SvHYg5LtQV6RBcK0if7ur6plyEukAOV+jGGPqFImuzu8fHL6M752iBmRGoUyF0bhZbAPoezehn7xYksA==
dependencies:
match-at "^0.1.0"
keyv@^4.5.3: keyv@^4.5.3:
version "4.5.4" version "4.5.4"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93"
...@@ -2425,6 +2432,13 @@ lru-cache@^5.1.1: ...@@ -2425,6 +2432,13 @@ lru-cache@^5.1.1:
dependencies: dependencies:
yallist "^3.0.2" yallist "^3.0.2"
markdown-it-katex@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/markdown-it-katex/-/markdown-it-katex-2.0.3.tgz#d7b86a1aea0b9d6496fab4e7919a18fdef589c39"
integrity sha512-nUkkMtRWeg7OpdflamflE/Ho/pWl64Lk9wNBKOmaj33XkQdumhXAIYhI0WO03GeiycPCsxbmX536V5NEXpC3Ng==
dependencies:
katex "^0.6.0"
markdown-it@^13.0.1: markdown-it@^13.0.1:
version "13.0.2" version "13.0.2"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-13.0.2.tgz#1bc22e23379a6952e5d56217fbed881e0c94d536" resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-13.0.2.tgz#1bc22e23379a6952e5d56217fbed881e0c94d536"
...@@ -2436,6 +2450,11 @@ markdown-it@^13.0.1: ...@@ -2436,6 +2450,11 @@ markdown-it@^13.0.1:
mdurl "^1.0.1" mdurl "^1.0.1"
uc.micro "^1.0.5" uc.micro "^1.0.5"
match-at@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/match-at/-/match-at-0.1.1.tgz#25d040d291777704d5e6556bbb79230ec2de0540"
integrity sha512-h4Yd392z9mST+dzc+yjuybOGFNOZjmXIPKWjxBd1Bb23r4SmDOsk2NYCU2BMUBGbSpZqwVsZYNq26QS3xfaT3Q==
mdurl@^1.0.1: mdurl@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment