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

Support for formatting SQL code blocks in Markdown #593

Open
michael-the1 opened this issue May 24, 2024 · 2 comments · May be fixed by #598
Open

Support for formatting SQL code blocks in Markdown #593

michael-the1 opened this issue May 24, 2024 · 2 comments · May be fixed by #598

Comments

@michael-the1
Copy link

It would be really nice if sqlfmt would support formatting SQL code blocks in Markdown files. In the context of dbt, this would also be very beneficial. We put a lot of example queries in our documentation and it would be amazing if they followed the same style.

Before

# Some title

Some text

```sql
SELECT * FROM some.table
```

After

# Some title

Some text

```sql
select * from some.table
```

In terms of requirements, I think limiting to sql blocks within .md files would be enough.

@tconbeer
Copy link
Owner

I like this idea.

I think we'd support this by installing a markdown parser as an extra (e.g., mistletoe or marko), iterating through the code blocks in the AST, and replacing their contents.

Right now we ignore .md files, but that can be changed via config.

PRs very welcome!

@michael-the1
Copy link
Author

Looks doable! I'm able to spend some time on this so I'll try to get a PR up sometime in the next two weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants