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

Add math rendering to posts using KaTeX #184

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Gravydigger
Copy link

What kind of changes does this PR include?

  • Changes with larger consequences (logic, library updates, etc.)

Description

Adds support of rendering TeX maths equations & symbols inside posts using KaTeX. Wrap a TeX statement with $$ to allow rendering.

Tex rendering before this PR:
no-latex

Tex rendering after this
latex

Copy link

netlify bot commented Dec 26, 2023

👷 Deploy request for astro-theme-cactus pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 7ef5717

@Gravydigger Gravydigger changed the title Add math rednering to posts using KaTeX Add math rendering to posts using KaTeX Dec 26, 2023
@chrismwilliams
Copy link
Owner

@Gravydigger thank you for doing this & sorry for taking so long, I'll get this merge by next week

@Gravydigger
Copy link
Author

After using this for a while, I have realised it does have some issues with the RSS Feed regarding rendering, for example:
Website:
image

RSS feed (I use Feeder):
Screenshot_20240120-083135

This is caused by KaTeX using CSS to render the text, as KaTeX shows both a nice formatted version as you see on the webpage, just also has a version for screen readers to parse, which is hidden, hence the repeating of text in RSS.

I only just now had a look at Astro's RSS documention, so a custom stylesheet might need to be implemented to fix these issues.

@Gravydigger
Copy link
Author

ok, having a look on how RSS works in general and how its set up in this template, it seems that when a RSS reader fetches the full article, its up to the RSS reader to format it. the only way to fix it would be to include the content directly into the rss.xml, which might be undesirable.

@chrismwilliams
Copy link
Owner

Ahh I see what you mean. That's a shame but I guess it makes sense it's all css. I know some readers will drop any custom stylesheet, so yeah you're probably right in that it's going to be including the content directly, which still might need 'cleaning-up'.

Umm. I'm not completely against adding the content directly, e.g. Astro's docs, but I'm guessing it's not going to be much better, unfortunately, but I'll see what output we get.

@Gravydigger
Copy link
Author

Here's the KaTeX docs if your curious and the stylesheet:
https://katex.org/docs/browser
<link href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css" rel="stylesheet">

Now KaTeX isn't the only option, as specified in the remark-math monorepo, MathJax being another option, but I wouldn't recommend. It has an option to turn the LaTeX into an SVG, but does break formatting on the website. The other options would require css aswell.

Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants