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 is not parsed if the last value is omitted #6248

Closed
kachkaev opened this issue Jun 24, 2019 · 4 comments
Closed

Markdown front matter is not parsed if the last value is omitted #6248

kachkaev opened this issue Jun 24, 2019 · 4 comments
Labels
area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:markdown Issues affecting Markdown lang:yaml Issues affecting YAML status:awaiting response Issues that require answers to questions from maintainers before action can be taken type:bug Issues identifying ugly output, or a defect in the program

Comments

@kachkaev
Copy link
Member

kachkaev commented Jun 24, 2019

Prettier 1.18.2
Playground link

--parser markdown

Input:
a few spaces after b

---
a:    42
b:    
---

content

Output:
no spaces after b

---
a: 42
b:
---

content

Second Output:

SyntaxError: Implicit map keys need to be followed by map values (2:1)
  1 | a: 42
> 2 | b:
    | ^^

Expected behavior:

b:\n--- is parsed just as b: \n--- or b: ~\n---

Swapping a and b (i.e. making so that the last line in YAML has value) helps avoid the exception. Also the same yaml in a separate file is formatted without problems.

@j-f1 j-f1 changed the title Makrdown frontmatter is not parsed if the last value is omitted Markdown front matter is not parsed if the last value is omitted Jun 24, 2019
@j-f1 j-f1 added area:api Issues with Prettier's Application Programming Interface area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:markdown Issues affecting Markdown lang:yaml Issues affecting YAML type:bug Issues identifying ugly output, or a defect in the program and removed area:api Issues with Prettier's Application Programming Interface labels Jun 24, 2019
@y9c
Copy link

y9c commented Mar 24, 2020

Also format in the wrong way when there is a empty line in the block.

input

---
a:  42
b:  43
 
---

# test

Output:

---
a: 42
b: 43

---#test

@thorn0
Copy link
Member

thorn0 commented Mar 24, 2020

The original issue seems to be gone.

@yech1990 please use the playground to reproduce your issue. I can't reproduce it.

@thorn0 thorn0 added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Mar 24, 2020
@y9c
Copy link

y9c commented Mar 24, 2020

@thorn0 sorry about that.
I got this error when using version 1.19. After upgrading prettier into version 2.0, it works properly now.

@thorn0
Copy link
Member

thorn0 commented Mar 24, 2020

Glad to hear that.

@thorn0 thorn0 closed this as completed Mar 24, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:markdown Issues affecting Markdown lang:yaml Issues affecting YAML status:awaiting response Issues that require answers to questions from maintainers before action can be taken type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

4 participants