Поделиться через


ConvertFrom-Markdown

Convert the contents of a string or a file to a MarkdownInfo object.

Синтаксис

PathParamSet (по умолчанию)

ConvertFrom-Markdown
    [-Path] <String[]>
    [-AsVT100EncodedString]
    [<CommonParameters>]

LiteralParamSet

ConvertFrom-Markdown
    -LiteralPath <String[]>
    [-AsVT100EncodedString]
    [<CommonParameters>]

InputObjParamSet

ConvertFrom-Markdown
    -InputObject <PSObject>
    [-AsVT100EncodedString]
    [<CommonParameters>]

Описание

This cmdlet converts the specified content into a MarkdownInfo. When a file path is specified for the Path parameter, the contents on the file are converted. The output object has three properties:

  • The Token property has the abstract syntax tree (AST) of the converted object
  • The Html property has the HTML conversion of the specified input
  • The VT100EncodedString property has the converted string with ANSI (VT100) escape sequences if the AsVT100EncodedString parameter was specified

This cmdlet was introduced in PowerShell 6.1.

Примеры

Example 1: Convert a file containing Markdown content to HTML

ConvertFrom-Markdown -Path .\README.md

The MarkdownInfo object is returned. The Tokens property has the AST of the converted content of the README.md file. The Html property has the HTML converted content of the README.md file.

Example 2: Convert a file containing Markdown content to a VT100-encoded string

ConvertFrom-Markdown -Path .\README.md -AsVT100EncodedString

The MarkdownInfo object is returned. The Tokens property has the AST of the converted content of the README.md file. The VT100EncodedString property has the VT100-encoded string converted content of the README.md file.

Example 3: Convert input object containing Markdown content to a VT100-encoded string

Get-Item .\README.md | ConvertFrom-Markdown -AsVT100EncodedString

The MarkdownInfo object is returned. The FileInfo object from Get-Item is converted to a VT100-encoded string. The Tokens property has the AST of the converted content of the README.md file. The VT100EncodedString property has the VT100-encoded string converted content of the README.md file.

Example 4: Convert a string containing Markdown content to a VT100-encoded string

"**Bold text**" | ConvertFrom-Markdown -AsVT100EncodedString

The MarkdownInfo object is returned. The specified string **Bold text** is converted to a VT100-encoded string and available in VT100EncodedString property.

Параметры

-AsVT100EncodedString

Specifies if the output should be encoded as a string with VT100 escape codes.

Свойства параметра

Тип:SwitchParameter
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-InputObject

Specifies the object to be converted. When an object of type System.String is specified, the string is converted. When an object of type System.IO.FileInfo is specified, the contents of the file specified by the object are converted. Objects of any other type result in an error.

Свойства параметра

Тип:PSObject
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

InputObjParamSet
Position:Named
Обязательно:True
Значение из конвейера:True
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-LiteralPath

Specifies a path to the file to be converted.

Свойства параметра

Тип:

String[]

Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False
Aliases:PSPath, LP

Наборы параметров

LiteralParamSet
Position:Named
Обязательно:True
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-Path

Specifies a path to the file to be converted.

Свойства параметра

Тип:

String[]

Default value:None
Поддерживаются подстановочные знаки:True
DontShow:False

Наборы параметров

PathParamSet
Position:0
Обязательно:True
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

CommonParameters

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

Входные данные

PSObject

Выходные данные

Microsoft.PowerShell.MarkdownRender.MarkdownInfo