Skip to content

Parse, modify and output Markdown using the Markdig engine

License

Notifications You must be signed in to change notification settings

aldrichtr/PSMarkdig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title status
PSMarkdig: A PowerShell module for working with markdown
prerelease

Synopsis

PSMarkdig is a module for parsing, modifying and writing markdown.

Overview

PowerShell already has built in functions for displaying markdown, such as ConvertFrom-Markdown and Show-Markdown.

Note These functions use the markdig library "under-the-hood".

If your goal is to convert existing markdown content into another format, such as HTML, then the built-in commands already provide that.

Get-Content README.md
  | ConvertFrom-Markdown
  | Select-Object -ExpandProperty HTML

Similarly, if you just want to display markdown content in the console, the built-in commands can do that too.

Show-Markdown README.md

You can even get to the markdig objects using ConvertFrom-Markdown

$tokens = Get-Content README.md
  | ConvertFrom-Markdown
  | Select-Object -ExpandProperty Tokens

But, what if you want to modify a markdown document...? such as add a heading, use the metadata in the frontmatter, or rearrange the content? That is where PSMarkdig comes in.

$doc = README.md | Import-Markdown -Extension 'advanced+yaml'
$mainHeadings = $doc | Get-MarkdownHeading -Level 2
# Change the second heading to a sub-heading of the first
$mainHeadings
   | Select-Object -First 1 -Skip 1
   | Set-MarkdownHeading -Level 3
$doc | Write-Markdown README.md

About

Parse, modify and output Markdown using the Markdig engine

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published