Skip to content
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

docs(v2): New doc page for math equations #4821

Merged
merged 2 commits into from
Jun 2, 2021
Merged

docs(v2): New doc page for math equations #4821

merged 2 commits into from
Jun 2, 2021

Conversation

pranabdas
Copy link
Contributor

@pranabdas pranabdas commented May 20, 2021

Motivation

Rendering LaTeX math equations is an important feature for many documentation sites. Although, it is possible to write math equations using Docusaurus, it is not documented in the Docs.

Have you read the Contributing Guidelines on pull requests?

Yes.

Test Plan

I have created a new file website/docs/guides/markdown-features/markdown-features-math-equations.mdx, and made changes to the sidebar configuration (website/sidebars.js) to include it in the sidebar. I have tested the doc website locally, and it works properly.

Related PRs

@pranabdas pranabdas requested review from lex111 and slorber as code owners May 20, 2021 15:47
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 20, 2021
@netlify
Copy link

netlify bot commented May 20, 2021

✔️ [V2]

🔨 Explore the source changes: 543d3fa

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60b772e3e9d6470008a9861a

😎 Browse the preview: https://deploy-preview-4821--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented May 20, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 51
🟢 Accessibility 97
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4821--docusaurus-2.netlify.app/

@pranabdas pranabdas changed the title docs (v2): New doc page for math equations docs(v2): New doc page for math equations May 20, 2021
@slorber
Copy link
Collaborator

slorber commented Jun 2, 2021

Hey, thanks for this doc

I've updated it a bit and enabled Katex on Docusaurus site for dogfooding and ensure this remains usable.

Helped me figure out some potential problems in versions (hast-util-is-element absolutely need to be 1.1.0 or it won't work)

@slorber slorber added the pr: documentation This PR works on the website or other text documents in the repo. label Jun 2, 2021
@netlify
Copy link

netlify bot commented Jun 2, 2021

✔️ [V1]

🔨 Explore the source changes: 543d3fa

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-1/deploys/60b772e390075e0008b49473

😎 Browse the preview: https://deploy-preview-4821--docusaurus-1.netlify.app

@slorber slorber merged commit 6d184a3 into facebook:master Jun 2, 2021
@pranabdas
Copy link
Contributor Author

Thank you for catching the dependencies. I did not test on Docusaurus website (was not sure if it would be good idea to change package.json). For me it worked fine on a cleanly built site:

npm i @docusaurus/core@latest @docusaurus/preset-classic@latest
npm i remark-math@3 rehype-katex

@slorber
Copy link
Collaborator

slorber commented Jun 3, 2021

rehype-katex has published v5 recently, I'm not sure it's compatible anymore. In any case I think it's preferable to lock to specific major versions as our doc may start failing other time when new incompatible majors are released

@pranabdas
Copy link
Contributor Author

I updated some of my Doc sites to rehype-katex v5 along with docusaurus v2-beta0 couple of weeks ago. Have not noticed any glitch yet (an example page with lots of math equations). But it make sense to lock major versions, and upgrade manually.

@slorber
Copy link
Collaborator

slorber commented Jan 20, 2022

hey @pranabdas , was wondering how did you decide to use an external cdn URL for this asset.

As I'm having network issues, this resource is blocking and preventing me to work locally easily

So I'll move the docusaurus site to self-hosted CSS to unblock me, but we should probably recommend users to do the same 🤷‍♂️

@pranabdas
Copy link
Contributor Author

Hello @slorber, I did not think about its pros and cons much. Probably there is not much of cons hosting katex.min.css locally, as it is only 23 KB and relatively low chance that it would be cached by the browser (because the user downloaded the same resource used in another website).

@pranabdas
Copy link
Contributor Author

@slorber I also realise that we need to host required katex fonts alongside katex stylesheet. Total asset size is ~1.2MB. Is that much build size increase acceptable? If you like, I can create a PR with proposed changes. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: documentation This PR works on the website or other text documents in the repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants