denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.5k stars 5.18k forks source link

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

Open oscarotero opened 1 year ago

oscarotero commented 1 year ago

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 commented 1 year ago

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.

evanleck commented 2 months ago

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 commented 2 months ago

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