jackyzha0 / quartz

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

Markdown Code in Code Block is Incorrectly Rendered #1020

Open bbohling opened 7 months ago

bbohling commented 7 months ago

Describe the bug

When creating a code block of GitHub's Alerts markdown, it is rendered incorrectly on the webpage. It has an extra space between the type and the text (see screenshot below).

To Reproduce Steps to reproduce the behavior:

  1. On a new page (markdown file) in Obsidian add the following code block:
> [!NOTE]
> Useful information that users should know, even when skimming content.

> [!TIP]
> Helpful advice for doing things better or more easily.

> [!IMPORTANT]
> Key information users need to know to achieve their goal.

> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.

> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
  1. Then build the site and look at the web page. You will see what is shown in the screenshot below.

Expected behavior

There should not be an extra > line in-between the type (Note, Tip, Important, ...) and the alert text.

Screenshots and Source

quartz-markdown-code-render-bug

Desktop (please complete the following information):

saberzero1 commented 7 months ago

The reason this happens is because of these lines in the Obsidian Flavored Markdown transformer:

https://github.com/jackyzha0/quartz/blob/de6f469011e15f82ddffa8aad75f628d1ca612da/quartz/plugins/transformers/ofm.ts#L127

https://github.com/jackyzha0/quartz/blob/de6f469011e15f82ddffa8aad75f628d1ca612da/quartz/plugins/transformers/ofm.ts#L167-L176

According to the Obsidian documentation, there is no need for a new line between the title and the body of a callout. https://help.obsidian.md/Editing+and+formatting/Callouts

I remember the newline being necessary to properly embed the callout, but it seems to have been fixed in Obsidian 0.14.8

I'll check if the code can be removed without impacting callout functionality. This should fix your issue as well.