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

fmt is not compatible with some front matters in markdown files #19458

Closed
oscarotero opened this issue Jun 10, 2023 · 5 comments
Closed

fmt is not compatible with some front matters in markdown files #19458

oscarotero opened this issue Jun 10, 2023 · 5 comments
Labels
deno fmt Related to the "deno fmt" subcommand or dprint

Comments

@oscarotero
Copy link
Contributor

The front matter std library supports different formats of frontmatters, but these formats are not recognized by fmt. For example, let's say I have the following markdown file with a TOML front matter:

+++
title = 'First page'
+++

Hello world

After running deno fmt, the file is changed to:

+++ title = 'First page' +++

Hello world

Now the front matter is no longer detected by the std library.

@vedant-pandey
Copy link
Contributor

Fmt relies on the package dprint-plugin-markdown which in turn uses pulldown-cmark. Right now metadata tags are not yet supported, but the required changes are already created, source here. As per the project specs it would get supported in pulldown-cmark in version 0.10 while the latest release is 0.9.3 which is the one supported in dprint-plugin-markdown.

@dsherret dsherret added deno fmt Related to the "deno fmt" subcommand or dprint enhancement labels May 8, 2024
@evanleck
Copy link

Just ran into this problem while building out a site using Lume and it looks like pulldown-cmark has released 0.10+ now https://github.com/pulldown-cmark/pulldown-cmark/releases

@evanleck
Copy link

Until this resolved, I'm using Prettier via deno eval, in case anyone wants a stop gap:

deno eval 'import "npm:prettier@3/bin/prettier.cjs";' -- --parser markdown

@KorigamiK
Copy link

Also related to formatting markdown files. Deno fmt cannot format file that have pandoc syntax also.
For example, formatting fails to happen in such cases which work fine with pandoc.
![Sandbox](./images/image.png){ width=80% }

@dsherret
Copy link
Member

This works now in 1.46 https://dprint.dev/playground/#code/NQiwCgBcEtIGwKYAIC8SDkAxaAnAzpEgA4CGA5guhCMBBABIJxwD2SA7iznACZA/plugin/markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno fmt Related to the "deno fmt" subcommand or dprint
Projects
None yet
Development

No branches or pull requests

5 participants