jackyzha0 / quartz

🌱 a fast, batteries-included static-site generator that transforms Markdown content into fully functional websites
https://quartz.jzhao.xyz
MIT License
7.37k stars 2.54k forks source link

Math block breaks callout #1547

Open NuclearGandhi opened 4 weeks ago

NuclearGandhi commented 4 weeks ago

Describe the bug Having a math block (display, not inline) in a callout, breaks the callout to two separate ones. I understand this probably has to do with remark-parse, but I want to make sure before I go into that rabbit hole.

{BDE8466E-C467-44DA-AB92-A34ECE0F2980}

To Reproduce

  1. Create a simple callout in a Markdown file:
    > [!NOTE] Title
    > ABCDEFG
    > $$v=\alpha_1e_1 + \dots +\alpha_ne_n$$
    > ABCDEFG
  2. Build.

Expected behavior In Obsidian we get: {78347F5E-EC9D-4421-8872-334041A9E5E7}

You can help speed up fixing the problem by either

  1. providing a simple reproduction
  2. linking to your Quartz repository where the problem can be observed

Desktop (please complete the following information):

Additional context

NuclearGandhi commented 2 weeks ago

I have solved the problem in a very time-consuming, maybe overkill, but ultimately satisfying way. I wrote a python script to clean up the syntax of my files, e.g. for the example above:

> [!NOTE] Title
> ABCDEFG
> $$v=\alpha_1e_1 + \dots +\alpha_ne_n$$
> ABCDEFG

turn this into something more readable by general markdown standards:

> [!NOTE] Title
> ABCDEFG
>$$
>v=\alpha_1e_1 + \dots +\alpha_ne_n
>$$
> ABCDEFG

The reason I needed such a script is because Obsidian isn't punishing at all when parsing its markdown files, so parsers like 'remark' have a very hard time when amateur markdown users (me) abuse the user-friendliness of Obsidian. Should this be written into a plugin to run as a transformer? Maybe, but it would be hard for the average user to debug it should the script mess something up.

NuclearGandhi commented 1 week ago

So in the end I actually did create a plugin - mathblock-fixer.ts. It probably still has a way to go, but it actually works quite well on my 500+ note vault.