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

deno fmt should format Markdown including code blocks #7352

Closed
David-Else opened this issue Sep 4, 2020 · 11 comments · Fixed by #8887
Closed

deno fmt should format Markdown including code blocks #7352

David-Else opened this issue Sep 4, 2020 · 11 comments · Fixed by #8887
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted) help wanted community help requested

Comments

@David-Else
Copy link

At the moment Deno only formats JS and TS, but dprint can also format markdown including JS and TS code blocks:

#6682 (comment)

This would be an awesome feature for documentation, is it possible to enable it? Then we can get rid of Prettier.

@bartlomieju
Copy link
Member

I think @dsherret is working on it

@bartlomieju
Copy link
Member

dprint has dprint-plugin-markdown which we could use for this purpose. I wonder if dprint-plugin-typescript could take an option to format markdown code blocks (which would make dprint-plugin-markdown its dependency?). @dsherret thoughts?

@bartlomieju bartlomieju added cli related to cli/ dir suggestion suggestions for new features (yet to be agreed) upstream Changes in upstream are required to solve these issues labels Nov 16, 2020
@dsherret
Copy link
Member

@bartlomieju why would it be that way instead of the other way around?

Though kind of not documented well, dprint-plugin-markdown has API for formatting code in markdown code blocks (see the third parameter): https://docs.rs/dprint-plugin-markdown/0.4.1/dprint_plugin_markdown/fn.format_text.html

I need to make dprint-plugin-markdown MIT, which I will do soon.

@bartlomieju
Copy link
Member

@dsherret thanks for pointing that out, indeed the other way around seems like a better option.

I need to make dprint-plugin-markdown MIT, which I will do soon.

No rush :)

@dsherret
Copy link
Member

dsherret commented Nov 21, 2020

@bartlomieju it's now MIT in 0.4.2.

By the way, regarding that format_text function's provided function, the first parameter is the code block tag, second param is file text, third is the current line width based on how much it's indented in the current markdown document.

@David-Else
Copy link
Author

I see a1a806a just landed in master :)

Can we use deno fmt myfile1.md and it also formats js/ts code blocks in the file?

@bartlomieju
Copy link
Member

I see a1a806a just landed in master :)

Can we use deno fmt myfile1.md and it also formats js/ts code blocks in the file?

@David-Else no, above commit changed only internal tooling used in repo, still need to implement it for deno fmt

@David-Else
Copy link
Author

David-Else commented Dec 23, 2020

@bartlomieju I think you can remove the upstream label now?

@bartlomieju bartlomieju added feat new feature (which has been agreed to/accepted) help wanted community help requested l-rust and removed upstream Changes in upstream are required to solve these issues suggestion suggestions for new features (yet to be agreed) labels Dec 24, 2020
@bartlomieju
Copy link
Member

bartlomieju commented Dec 24, 2020

@bartlomieju I think you can remove the upstream label now?

@David-Else sure I removed it and added appropriate labels, I've also renamed the issue

@bartlomieju bartlomieju changed the title [Feature Request] Enable Markdown formatting deno fmt should format Markdown in code blocks Dec 24, 2020
@David-Else
Copy link
Author

@bartlomieju Thanks.

The title is wrong for what I was requesting. Deno needs to format Markdown, that is .md files. That needs to include formatting code blocks inside that markdown.

There is no 'Markdown in code blocks'. The code blocks are in the Markdown. A better title would be deno fmt should format Markdown including code blocks. You might want to specify what types of code blocks are covered, JS and TS I assume.

@bartlomieju bartlomieju changed the title deno fmt should format Markdown in code blocks deno fmt should format Markdown including code blocks Dec 24, 2020
@satyarohith
Copy link
Member

I'll take a stab at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted) help wanted community help requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants