13 Feb
2013

It’s Markdown, no, PowerShell. Wait its Markdown formatted PowerShell.

I created an introductory presentation on PowerShell a while back and posted it on my GitHub. I first gave the presentation at the NNSDG and decided to also submit it as a talk to the Boise Code Camp this year. (Looks like I’ll be going ? track me down @staxmanade if you?d like to say hello)

I?ve become quite a fan of Markdown lately and thought, ?what if this not only looked like PowerShell, but looked even better as Markdown???

 

After experimenting a little, I found that it actually works quite well.

For example:

PowerShell (Markdown)

## String Interpolation

### Single quotes `don't` interpolate
    'Hello $groupName' 
    
### Double quotes `DO` interpolate
    "Hello $groupName"
        
    
### Wrap `$(...)` around expression within an string
    "groupName variable is of type: $($groupName.GetType().FullName)"
    "2 + 1564 = $(2 + 1564)"
    "Current DateTime is = $(get-date)"
    "Current DateTime is = $([System.DateTime]::Now)"

    
### Escape characters with the ` (back-tick)
    "Escape a quotation `"This is quoted`"."

 

Formatted Markdown

image

 

One issue I have is the way GitHub/markdown formats extra whitespace (it doesn?t). So I?ve worked around that so that I can get the vertical whitespace that I need in the Markdown version by placing a link to a spacer image:

![vertical space](http://is.gd/VertSpace)

This isn?t ideal because my PowerShell is littered with this snippet, but something that can easily be search/replaced before using the raw version as a PowerShell script.

I also think that you could potentially do this with many different programming languages. (At least ones that don?t depend on whitespace and have a form of block comments)

Nifty eh?

Happy PowerDowning or MarkShelling!

One thought on “It’s Markdown, no, PowerShell. Wait its Markdown formatted PowerShell.”

Comments are closed.

Find me

RSS
Facebook
LinkedIn

Disclaimer

The opinions and content expressed here are my own and not those of my employer.