Skip to content

Helper for formatting web documents in Markdown, Html, or Confluence.

License

Notifications You must be signed in to change notification settings

cdhunt/Format-Document

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Format-Document

This module contains an HTML-like DSL for dynamically constructing documents using PowerShell. The same template can be rendered to any one of the following formats which render as similarly as possible.

Formats supported:

You can use this to automatically maintain and synchronize documentation in multiple formats such as READMEs and Confluence Wiki.

CI Status

GitHub Workflow Status (with event) Testspace pass ratio PowerShell Gallery

Build history

Install

powershellgallery.com/packages/Format-Document

Install-Module -Name Format-Document or Install-PSResource -Name Format-Document

PowerShell Gallery

Docs

Full Docs

Examples

Generate a document in Markdown. Each element accepts either a ScriptBlock or a String. Use a ScriptBlock if you want more powerful text generation. Unenclosed text will be passed through as is.

New-Document -Type Markdown {
    H1 "My Text"
    H2 { "Heading 2" }
    P { Get-Date }
    P {
        "normal text"
        B "bold text cmdlet"
        "."
        Link "link Text" "https://google.com"
    }
    Table {
        TR {
            TH "Heading 1","Heading 2"
        }
        TR {
            TD -Text "Fun"
            TD -Text "Moar Fun"
        }
        TR {
            TD "Item 1","Item 2"
        }
    }
}

markdown example


Using the same template and changing -Type parameter to Confluence renders the document in Confluence Storage Format.

confluence example

You can use ConfluencePS to publish the content.

$page = Get-ConfluencePage -PageID 123456789
$doc = New-Document -Type Confluence { ... }

$page.Body = $doc
$page | Set-ConfluencePage

Releases

No releases published

Packages

No packages published