Skip to content

Instantly share code, notes, and snippets.

@cdhunt
Last active May 26, 2016 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdhunt/06b2a0f54a7e75722457580710357e72 to your computer and use it in GitHub Desktop.
Save cdhunt/06b2a0f54a7e75722457580710357e72 to your computer and use it in GitHub Desktop.
A custom type file to help generate markdown
<?xml version="1.0" encoding="utf-8" ?>
<Types>
<Type>
<Name>System.String</Name>
<Members>
<ScriptMethod>
<Name>MarkdownStrong</Name>
<Script>
[OutputType([System.String])]
param()
"**{0}**" -f $this
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownEm</Name>
<Script>
[OutputType([System.String])]
param()
"_{0}_" -f $this
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownHeader</Name>
<Script>
[OutputType([System.String])]
param([ValidateRange(1,6)][int]$Level = 1)
"`n`r" + ("#" * $Level) + ' ' + $this + "`n`r"
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownQuote</Name>
<Script>
[OutputType([System.String])]
param([int]$Level = 0)
$this | foreach { " $(' ' * $Level * 2) > $($_.ToString())" }
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownLink</Name>
<Script>
[OutputType([System.String])]
param([string]$Uri)
"[$this]($Uri)"
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownCodeBlock</Name>
<Script>
[OutputType([System.String])]
param([string]$Language)
"``````$Language"
$this.ToString()
'```'
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownUL</Name>
<Script>
[OutputType([System.String])]
param([int]$Level = 0)
" $(' ' * $Level * 2) * $this"
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownOL</Name>
<Script>
[OutputType([System.String])]
param([int]$Level = 0)
" $(' ' * $Level * 2) 1. $this"
</Script>
</ScriptMethod>
</Members>
</Type>
<Type>
<Name>System.Management.Automation.ScriptBlock</Name>
<Members>
<ScriptMethod>
<Name>MarkdownCodeBlock</Name>
<Script>
[OutputType([System.String])]
param()
'```powershell'
$this.ToString()
'```'
</Script>
</ScriptMethod>
</Members>
</Type>
<Type>
<Name>System.Array</Name>
<Members>
<ScriptMethod>
<Name>MarkdownUL</Name>
<Script>
[OutputType([System.String])]
param([int]$Level = 0)
$this | foreach { " $(' ' * $Level * 2) * $($_.ToString())" }
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownOL</Name>
<Script>
[OutputType([System.String])]
param([int]$Level = 0)
$this | foreach { " $(' ' * $Level * 2) 1. $($_.ToString())" }
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>MarkdownQuote</Name>
<Script>
[OutputType([System.String])]
param([int]$Level = 0)
$this | foreach { " $(' ' * $Level * 2) > $($_.ToString())" }
</Script>
</ScriptMethod>
</Members>
</Type>
</Types>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment