dprint-plugin-markdown icon indicating copy to clipboard operation
dprint-plugin-markdown copied to clipboard

Support more code fence formatter plugins

Open nzoschke opened this issue 1 month ago • 6 comments

Can we make it so this formatter can be configured to call out to any plugin by code fence hint?

Right now it requires an explicit map in the plugin code. It would be nice to get these PRs in there:

  • https://github.com/dprint/dprint-plugin-markdown/pull/144
  • https://github.com/dprint/dprint-plugin-markdown/pull/143
  • https://github.com/dprint/dprint-plugin-markdown/pull/142

Then I am working on a plugin for a far less popular language https://cuelang.org/.

It would be great if there was a way to experiment and support all languages through config versus having to release a new version of the markdown plugin.

nzoschke avatar Oct 15 '25 20:10 nzoschke

@nzoschke if you'd like to submit a pr for it, go for it! I merged all those prs and will do a release in a bit.

dsherret avatar Oct 15 '25 20:10 dsherret

The hard part is there needs to be a mapping configured for code fence tag to extension. So probably there would need to be some config where that could be defined.

dsherret avatar Oct 15 '25 20:10 dsherret

Nice thanks for merging those other PRs! As a fallback I can open a similar one for my plugin someday.

But since you're into the idea I'll take a crack at a configuration mapping soon too.

nzoschke avatar Oct 15 '25 20:10 nzoschke

Yup. Thanks!

dsherret avatar Oct 15 '25 20:10 dsherret

A design sketch

dprint config:

{
  "markdown": {
    "tags": {
      "cue": "cue",
      "cuelang": "cue"
    }
  },
  "plugins": [
    "https://plugins.dprint.dev/typescript-0.95.11.wasm",
    "https://plugins.dprint.dev/json-0.20.0.wasm",
    "https://plugins.dprint.dev/markdown-0.19.0.wasm",
    "https://plugins.dprint.dev/cue-0.1.0.wasm"
  ]
}

Main design question is the config key and format. The code is tag_to_extension and "typescript" | "ts" => Some("ts") which is where my sketch is from.

nzoschke avatar Oct 15 '25 20:10 nzoschke

That looks good. Not sure about the name "tags", but we can decide on something before merging.

dsherret avatar Oct 15 '25 20:10 dsherret