microsoft / vscode-powerquery

Visual Studio Code extension for Power Query / M.
MIT License
86 stars 16 forks source link

[Enhancement] Add Power Query / M syntax highlighting to VS Code Markdown #205

Open UWE-BIDEV opened 1 year ago

UWE-BIDEV commented 1 year ago

Would it be possible to support syntax highlighting in markdown files, please? I've tried various keywords (i.e PowerQuery, powerquery, pq, mscript) and none of them seem to work in code blocks.

Many thanks

noah-severyn commented 11 months ago

@UWE-BIDEV at least on Github, you can tag the code as fs. PQ is very similar to the F# language (source).

mattmasson commented 5 months ago

Changed the title of the issue. This isn't really related to the vscode-powerquery extension, but I'll keep the issue here for tracking. I've looked into enabling M syntax highlighting for common markdown rendering engines in the past. Each one does it a bit differently. I believe github still uses linguist. We had originally created a separate github repo for efforts around language definition files (https://github.com/microsoft/powerquery-language/), but we haven't been keeping it up to date. Ideally we'd have a centralized place to validate, test, and generate grammars used for this to make updates more sustainable.

We'd be happy to help out any community members that want to drive this effort, but I don't think we'll have much bandwidth to take it on ourselves in near future.

UWE-BIDEV commented 5 months ago

Hi @mattmasson, thanks for your reply! This relates to VS Code, not GitHub, so I updated the title. :)

It would be good if syntax highlighting for Power Query code blocks worked by default when reading markdown files in VS Code.

I found a workaround (albeit a clunky one) using the Markdown Preview VS Code Highlighting extension (Link to visual studio marketplace here)

The version of shiki.js used in the extension didn't support Power Query / M yet, so I had to download the language file from GitHub and add it to the relevant folder. C:\Users\Username.vscode\extensions\bierner.markdown-shiki-0.1.1\node_modules\shiki-languages\data\grammars Then I had to add the keyword powerquery / pq into all the extension files as appropriate.