Skip to content

Convert-MarkdownToHTML

SYNOPSIS

Convert Markdown files to static HTML files.

SYNTAX

Convert-MarkdownToHTML [-Path] <String> [[-Template] <String>] [[-IncludeExtension] <String[]>]
 [[-ExcludeExtension] <String[]>] [[-MediaDirectory] <String>] [-SiteDirectory] <String> [<CommonParameters>]

DESCRIPTION

This function reads all Markdown files from a source folder and converts each of them to a standalone html document using:

  • configurable [Markdown extensions](about_MarkdownToHTML.md#supported-markdown-extensions)
  • a customizable or default HTML template. See `New-HTMLTemplate` about the creation of custom templates.

EXAMPLES

EXAMPLE 1

Convert-MarkdownToHTML -Path 'E:\MyMarkdownFiles' -SiteDirectory 'E:\MyHTMLFiles'

Convert all Markdown files in `E:\MyMarkdownFiles` and save the generated HTML files to `E:\MyHTMLFiles`.

EXAMPLE 2

Convert-MarkdownToHTML -Path 'E:\MyMarkdownFiles' -Template 'E:\MyTemplate' -SiteDirectory 'E:\MyHTMLFiles'

Convert all Markdown files in `E:\MyMarkdownFiles` using the 'common' parsing configuration and the custom template in `E:\MyTemplate`.

The generated HTML files are saved to `E:\MyHTMLFiles`.

EXAMPLE 3

Convert-MarkdownToHTML -Path 'E:\MyMarkdownFiles' -SiteDirectory 'E:\MyHTMLFiles' -IncludeExtension 'advanced','diagrams'

Convert all Markdown files in `E:\MyMarkdownFiles` using the 'advanced' and 'diagrams' parsing extension and the default template.

The generated HTML files are saved to `E:\MyHTMLFiles`.

EXAMPLE 4

Convert-MarkdownToHTML -Path 'E:\MyMarkdownFiles' -MediaDirectory 'e:\Media' -SiteDirectory 'E:\MyHTMLFiles' -IncludeExtension 'advanced','diagrams'

Convert all Markdown files in `E:\MyMarkdownFiles` using * the 'advanced' and 'diagrams' parsing extension. * the default template * Media files (images, Videos, etc.) from the directory `e:\Media`

The generated HTML files are saved to the directory `E:\MyHTMLFiles`.

PARAMETERS

-Path

Path to Markdown files or directories containing Markdown files.

Type: System.String
Parameter Sets: (All)
Aliases: Markdown

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Template

Optional directory containing the html template file `md-template.html` and its resources. If no template directory is specified, the factory-installed default template is used. For information about creating custom templates see `New-HTMLTemplate`.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: (Join-Path $SCRIPT:moduleDir.FullName 'Template')
Accept pipeline input: False
Accept wildcard characters: False

-IncludeExtension

Comma separated list of Markdown parsing extensions to use. See [about_MarkdownToHTML](MarkdownToHTML.md#markdown-extensions) for an annotated list of supported extensions.

Type: System.String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: @('common')
Accept pipeline input: False
Accept wildcard characters: False

-ExcludeExtension

Comma separated list of Markdown parsing extensions to exclude. Mostly used when the the 'advanced' parsing option is included and certain individual options need to be removed,

Type: System.String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: @()
Accept pipeline input: False
Accept wildcard characters: False

-MediaDirectory

An optional directory containing additional media for the Html site such as images, videos etc. Defaults to the directory given in `-Path`

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: $Path
Accept pipeline input: False
Accept wildcard characters: False

-SiteDirectory

Directory for the generated HTML files. The Html files will be placed in the same relative location below this directory as related Markdown document has below the Markdown source directory.

Type: System.String
Parameter Sets: (All)
Aliases: Destination

Required: True
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

This function does not read from the pipe.

OUTPUTS

File objects [System.IO.FileInfo] of the generated HTML files.

NOTES

https://wethat.github.io/MarkdownToHtml/2.5.0/Convert-MarkdownToHTML.html

New-HTMLTemplate

[Markdown extensions](about_MarkdownToHTML.md#supported-markdown-extensions)

Back to top