deno icon indicating copy to clipboard operation
deno copied to clipboard

fmt is not compatible with some front matters in markdown files

Open oscarotero opened this issue 2 years ago • 3 comments
trafficstars

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.

oscarotero avatar Jun 10 '23 11:06 oscarotero

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.

vedant-pandey avatar Jun 11 '23 10:06 vedant-pandey

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 avatar May 13 '24 21:05 evanleck

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

evanleck avatar May 16 '24 17:05 evanleck

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% }

KorigamiK avatar Jul 31 '24 08:07 KorigamiK

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

dsherret avatar Aug 23 '24 14:08 dsherret