Skip to content
New issue

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

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

Already on GitHub? # to your account

Frontmatter yaml is converted to *** #22

Closed
4 tasks done
coderaiser opened this issue Feb 4, 2025 · 2 comments
Closed
4 tasks done

Frontmatter yaml is converted to *** #22

coderaiser opened this issue Feb 4, 2025 · 2 comments
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on

Comments

@coderaiser
Copy link

coderaiser commented Feb 4, 2025

Initial checklist

Affected package

latest

Steps to reproduce

Github issues templates uses yaml, and when I lint with remark the resulting markdown is being corrupted.

import remarkFrontmatter from 'remark-frontmatter'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import {unified} from 'unified'

const md = `
---
layout: "solar-system"
---

# Jupiter
`;

const file = await unified()
  .use(remarkParse)
  .use(remarkStringify)
  .use(remarkFrontmatter, ['yaml'])
  .use(function () {
    return function (tree) {
      console.dir(tree)
    }
  })
  .process(md)

console.log(String(file))

Actual behavior

***

## layout: "solar-system"

# Jupiter

Expected behavior

---
layout: "solar-system"
---

# Jupiter

Runtime

No response

Package manager

No response

Operating system

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Feb 4, 2025
@ChristianMurphy
Copy link
Member

Welcome @coderaiser 👋
Frontmatter starts on the first line of a file, you have it on the second so it isn't recognized.
Try

const markdown = `---
layout: "solar-system"
---

# Jupiter
`;

Runnable example: https://stackblitz.com/edit/github-uw6tjlky?file=src%2Fmain.ts

@ChristianMurphy ChristianMurphy closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2025
@ChristianMurphy ChristianMurphy added the 🙋 no/question This does not need any changes label Feb 4, 2025

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Feb 4, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants