astro-theme-cactus icon indicating copy to clipboard operation
astro-theme-cactus copied to clipboard

Add math rendering to posts using KaTeX

Open Gravydigger opened this issue 1 year ago • 8 comments

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

Gravydigger avatar Dec 26 '23 05:12 Gravydigger

Deploy request for astro-theme-cactus rejected.

Name Link
Latest commit a36c64d906c9abb34f2051770da7dcad5fc64a7e

netlify[bot] avatar Dec 26 '23 05:12 netlify[bot]

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

chrismwilliams avatar Jan 19 '24 15:01 chrismwilliams

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 avatar Jan 19 '24 22:01 Gravydigger

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.

Gravydigger avatar Jan 19 '24 23:01 Gravydigger

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.

chrismwilliams avatar Jan 22 '24 10:01 chrismwilliams

Here's the KaTeX docs if your curious and the stylesheet: https://katex.org/docs/browser <link href="https://cdn.jsdelivr.net/npm/[email protected]/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.

Gravydigger avatar Jan 22 '24 11:01 Gravydigger

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.

github-actions[bot] avatar Feb 21 '24 23:02 github-actions[bot]

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.

github-actions[bot] avatar Aug 18 '24 23:08 github-actions[bot]