Displaying Markdown

I document various infrastructure aspects in Markdown files for my own use. However, I’d like to be able to “publish” these to a PSU dashboard. In GitHub/GitLab, they “natively” display markdown files. For instance:

## **AAD Connect Configuration**

#### **Viewing Current Configuration**

1. Login to primary server
2. Launch 'Azure AD Connect' application
3. Choose *Configure*
4. Select *View or export current configuration* and click **Next**
5. The current configuration is displayed

![AAD Connect Cofiguration](/Azure/Imgs/AADConfig.png)

In GitLab will display as:

I’m trying to come up with an automated way to do this in PSU. Currently, the closest I have come to is using ConvertFrom-MarkDown PowerShell cmdlet. For example:

$MarkdownTest = New-UDPage -Name 'Markdown Test' -Content {
    $MarkdownContent = ConvertFrom-MarkDown -Path 'C:\SomeMarkDownFile.md'
    New-UDHtml -Markup $MarkdownContent.Html
} -Url '/MarkdownTest'

Which displays as:

I’ve tried playing with the file path reference in the Markdown formatting but all have failed to get images to appear.

I saw a Markdown dashboard in the marketplace, but looks like it was for authoring Markdown within PSU, whereas I basically want to achieve what already is being done in GitHub/GitLab. Since we already use RBAC/Tags (which are awesome) in PSU, I was hoping there is a fairly straightforward way to achieve the same display results in PSU. Otherwise I’ll have to duplicate all the work and staff will have to create Github/GitLab accounts they don’t already have, which would be a bummer.

Is anyone doing something like this with Markdown already that can share some ideas/tips?

Product: PowerShell Universal
Version: 2.3.1

What’s the image path look like? It seems like what you’re doing should work.

I’ve tried relative paths and specifying the full path. Some examples:

![AAD Connect Configuration](/AADConfig.png)
![AAD Connect Configuration](/Azure/Imgs/AADConfig.png)
![AAD Connect Configuration](D:\PSU\Documentation\Azure\Imgs\AADConfig.png)
![AAD Connect Configuration](D:/PSU/Documentation/Azure/Imgs/AADConfig.png)
![AAD Connect Configuration](\Azure\Imgs\AADConfig.png)

None of the above formats worked. I am running PSU via IIS. AppPool is running as local system so I verified SYSTEM had rights to the folder where the images live. But still no go. Wasn’t sure if something with the markdown → HTML conversion and escaping those characters or how Markdown handles relative paths would explain it, but even with the full literal path it doesn’t appear to work.

You’ll need to make sure you have a published folder to host those images.

That will serve the images through the website. You’ll be able to create a path like \Azure\Imgs and then reference those in the markdown.

Thanks @adam, in that case would it be best to publish the entire Git repo to the Published Folder? My thought is I can reference that same relative path in the page PS1 file. Or is that not possible/supported currently?

I would not suggest to publish the enter repository since it will expose the entire configure of your PSU instance.

Since you can define what ever URL you want in the published folder, you should be able to publish the sub folders.

Markdown would be:


Layout of the repository folder would be:

- Repository
    - markdown.md
    - Azure
        - imgs 
            - myimage.png

Published folder configuration:

New-PSUPublishedFolder -Path C:\ProgramData\UniversalAutomation\Repository\Azure -RequestPath /Azure 

…and the lightbulb illuminates :D. That makes perfect sense, thanks.!

1 Like