Skip to content

Conversation

Jonathan2k19
Copy link
Contributor

Description

Disclaimer: I only tested this with the math shown in the description of /jobs/b6187b88-a423-4ab4-94d2-e7eba2b0bd25. It might be that this doesn't work on other sites.

Markdown KaTeX (i.e. math) didn't render correctly for the above-mentioned job.
Relevant input:

math: $e^{\pi i}=-1$
$$\sum_{i=1}^\infty i = -rac 1{12}$$

Relevant output:
before_katex

There were a few problems:

  • The job description seems to contain a unicode character in the description just before rac, which caused the shown error.
    • I tried to fix this by cleaning the tex input before passing it to katex.renderToString.
  • The markdown.ts file only checked for display math which is surrounded by $$, but not for inline math which is surrounded by $.
    • I tried to fix this by rewriting a bit of logic and passing { displayMode: isDisplayMath } to katex.renderToString.
  • The markdown.ts file didn't contain the katex.min.css. This can cause KaTeX to render two outputs (see this discussion).
    • I imported the said CSS.

Now, the output to the above input looks like:
after_katex

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Translation updates (fix/improve or add new translations)

Related to Bootstrap-Academy/Bootstrap-Academy#76

My Bootstrap Academy username: jonathan123456789

**Disclaimer**: I only "tested" this with the math shown in the
description of `/jobs/b6187b88-a423-4ab4-94d2-e7eba2b0bd25`.
@TheMorpheus407
Copy link
Contributor

This PR implements KaTeX support across various sections—specifically, for Jobs and Challenges, as demonstrated by the following links:

Currently, KaTeX rendering does not function as expected in Quizzes, which can be seen here.

If you could update to include quizzes with multiline support as well, we can merge :)

@Jonathan2k19
Copy link
Contributor Author

Hi,
I tried to fix KaTeX for quizes as well.

Before: see here
After: see here

I'm not sure if I understood what you meant with "multiline support" correctly.
I interpreted it as "don't truncate the line with ... if the content exceeds the length" as done previously due to the class="... clamp line-2":
no-multiline

TheMorpheus407
TheMorpheus407 previously approved these changes Nov 1, 2024
Copy link
Contributor

@TheMorpheus407 TheMorpheus407 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working quite well :) Code is good as well. @Defelo please review and merge if okay

Copy link
Member

@Defelo Defelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the challenges page KaTeX rendering still seems to be missing:

image

Copy link

github-actions bot commented Nov 1, 2024

Preview deployed to https://f9326442.academy-preview.pages.dev (total size: 15M)

@Jonathan2k19
Copy link
Contributor Author

On the challenges page KaTeX rendering still seems to be missing:

Yeah, I missed that one... Should work now, see here.

@Defelo Defelo merged commit 21ca1be into Bootstrap-Academy:develop Nov 1, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants