satnaing / astro-paper

A minimal, accessible and SEO-friendly Astro blog theme
https://astro-paper.pages.dev/
MIT License
2.49k stars 518 forks source link

[BUG]: Block Equation Color Rendering Issue Outside of Lists in AstroPaper #412

Open jonathanhu237 opened 4 hours ago

jonathanhu237 commented 4 hours ago

Describe the bug When using the AstroPaper theme with KaTeX for math formula rendering, block equations outside of lists display a color rendering issue. Specifically, the color of these block equations does not adapt to the theme's color scheme (e.g., dark/light mode) and remains fixed at #374151. In contrast, block equations placed inside lists render correctly and respond to the theme's color changes.

To Reproduce Steps to reproduce the behavior:

  1. Create the project by running:
    npm create astro@latest -- --template satnaing/astro-paper
  2. Add the LaTeX integration by following the official tutorial..
  3. Create a new blog post with the following content to test block equation rendering:
---
author: author
pubDatetime: 2024-11-08T02:09:57.000+08:00
modDatetime:
title: LaTeX
featured: false
draft: true
tags:
  - LaTeX
description: LaTeX
---

Block Equation outside the list:

$$
\int\_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$

Block Equation inside the list:

1. $$
   \int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
   $$

Expected Behavior Both block equations (inside and outside of lists) should have consistent color rendering and should automatically adapt to the theme's color scheme (dark/light mode).

Actual Behavior

Screenshots image image

jonathanhu237 commented 3 hours ago

Using the browser's developer tools, I observed that block equations outside lists do not inherit certain CSS properties that are applied to those inside lists.

The figure below shows the CSS properties applied to a block equation within a list. image

The figure below displays the properties for a block equation outside a list. image

To temporarily address this issue, I added the following CSS:

span.katex-display {
  @apply text-skin-base;
}

This fix forces the correct color on the block equation. However, I am not certain if this is the optimal solution or if it may introduce other styling issues. And advice on a more robust fix would be appreciated.