Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown front matter highlighting not the same as YAML? #3283

Closed
Josh-Cena opened this issue Dec 27, 2021 · 2 comments
Closed

Markdown front matter highlighting not the same as YAML? #3283

Josh-Cena opened this issue Dec 27, 2021 · 2 comments

Comments

@Josh-Cena
Copy link

Information

  • Language: Markdown
  • Plugins: none

Description

YAML keys and values have different highlighting; however, all Markdown front matter is treated as plain string.

I'm aware that #2634 adds support for front matter, but that still doesn't make front matter displayed the same as YAML.

Highlight as MD Highlight as YAML
image image

Code snippet

Test page

The code being highlighted incorrectly.
---
id: 1
title: Hello
---

## Hello 

aaa
@RunDevelopment
Copy link
Member

It does work, it's just a little difficult to do on the test page.

image

Prism's languages have dependencies. I.e. Markdown (optionally) depends on YAML to highlight front matter. Prism does not resolve dependencies itself and assumes that languages are loaded in the correct order to satisfy all their dependencies. I.e. YAML has to be loaded before Markdown; Markdown won't be able to see YAML otherwise.

So to see front matter being highlighted on the test page, you have to do the following:

  1. Enter your MD code on the test page.
  2. Select the YAML language.
  3. Reload the page. (This will cause the test page to unload all languages and then load only YAML.)
  4. Select the Markdown language. (Markdown will now be loaded. Since YAML has been loaded before Markdown, Markdown will be able to see YAML and use it for front matter.)

I know that this is quite cumbersome, but this very manual approach to language loading on the test page is great for testing.

@Josh-Cena
Copy link
Author

Thanks for your explanation! I've managed to fix it on our side.

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

No branches or pull requests

2 participants