Creating Markdown files is something that I do regularly, usually in Visual Studio Code or Obsidian. But when working in a Windows Terminal or a standard PowerShell prompt, it’s nice to display those .md files in those, too, with all the formatting that Markdown gives you. In this blog post, I will show you how 🙂
What is Markdown?
“Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents. Created by John Gruber in 2004, Markdown is now one of the world’s most popular markup languages.
Using Markdown is different than using a WYSIWYG editor. In an application like Microsoft Word, you click buttons to format words and phrases, and the changes are visible immediately. Markdown isn’t like that. When you create a Markdown-formatted file, you add Markdown syntax to the text to indicate which words and phrases should look different.
For example, to denote a heading, you add a number sign before it (e.g., # Heading One). Or to make a phrase bold, you add two asterisks before and after it (e.g., **this text is bold**). It may take a while to get used to seeing Markdown syntax in your text, especially if you’re accustomed to WYSIWYG applications.”
Source: https://www.markdownguide.org/getting-started/
PowerShell cmdlets
In the Microsoft.PowerShell.Utility module (Only in the PowerShell 7 version), there are four cmdlets available:

In the chapters below, I will explain how they work, including examples:
ConvertFrom-Markdown
This cmdlet will convert an existing .md file to HTML or VT100 output. In the command line below, I convert a speedtest.md file to the speedtest.htm file:

I used ‘(Get-Item .\speedtest.md | ConvertFrom-Markdown).Html’ because, by default, the ConvertFrom-Markdown will output it to a MarkdownInfo object type:

The speedtest.html file looks like this:

You can also output it to a VT100 encoded string using:

When you display that in your Windows Terminal, it will look like this:

More information: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertfrom-markdown?view=powershell-7.4
Get-MarkdownOption
This will show you the current color and style options for showing Markdown files. For example:

More information: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-markdownoption?view=powershell-7.4
Set-MarkdownOption
Using Set-MarkdownOption you can configure the options like the ones displayed above in the Get-MarkDownOption chapter:

The easiest one to use, you can customize what you want, of course, is the -Theme parameter. You can specify Dark or Light. Depending on your preference, I’m Team Dark :-D.
More information: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/set-markdownoption?view=powershell-7.4
Show-Markdown
The Show-Markdown cmdlet will display a .md file in VT100 in the Terminal or a browser. For example:

Or in a browser using the -UseBrowser parameter:

More information: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/show-markdown?view=powershell-7.4
Wrapping up
In the chapters above, I showed you the Markdown cmdlets that PowerShell 7 has. These cmdlets allow you to view or convert data from .md files without leaving the Terminal. Have a lovely weekend!