More Pandoc and PowerShell Possibilities
Let's pick up where we left off, exploring how to use the pandoc utility to convert markdown files to HTML. In the previous post, we looked at the basics of using pandoc to convert a markdown file to HTML. We also explored some of the options for customizing the output. Today, we'll look at some additional options and features that you might find useful. And I promise, I'll get to some PowerShell. Although, there is nothing stopping you from using pandoc with PowerShell. That's what I have been doing for all of my examples.
Other HTML Options
I've been focusing on converting Markdown documents to HTML and there are a few more options you might find useful. I'll use this sample markdown document as an example.
# Sample Markdown Document
![Look at PowerShell](look-ps.jpg)
This is a sample Markdown document that is about PowerShell.
## Using CIM
I'll put first-level content here.
```powershell
Get-CimInstance Win32_OperatingSystem |
Select-Object RegisteredUser,InstallDate,
@{Name="OS";Expression = {$_.Caption}},
@{Name="Computername";Expression={$_.CSName}}
```
### Subsection 1
Here is a subsection where I might drone on and on about something.
## Using Aliases
It is easy to create aliases for other PowerShell commands.
```powershell
Set-Alias -Name gd -Value Get-Date
```
Or set an alias for any command.
```powershell
Set-Alias rdp mstsc.exe
```
## Summary
This concludes this sample document.
You can find me online [here](https://jdhitsolutions.github.io).
No Highlighting
As I showed last time, you can configure syntax highlighting. But you can also disable it.
pandoc -s -o sample-1.html sample-1.md --no-highlight -V backgroundcolor="#d2ddf1" -V date-meta=$(Get-Date) -V author-meta="Jeff Hicks" -V pagetitle="Converted Markdown Document" --quiet
The code sample is still formatted but without syntax highlighting.
Embedding Images
Another feature you might want to take advantage of is embedding images. My sample Markdown file has a link to a local image. By default, pandoc will respect that link.
However, this means that I cannot move the HTML file without also moving the image. If my goal is to create a standalone HTML file, I can embed the image.
pandoc -s -o sample-embed.html sample-1.md --embed-resources="True" --highlight-style="tango" -V backgroundcolor="#e6e8ec" -V date-meta=$(Get-Date) -V author-meta="Jeff Hicks" -V pagetitle="Converted Markdown Document"