Use Markdig from PowerShell #183

Closed
opened 2026-01-29 14:29:42 +00:00 by claunia · 3 comments
Owner

Originally created by @datenschieber on GitHub (Jan 18, 2018).

I am trying to use Markdig from PowerShell. Addtype .\Markdig.dll runs without problems. The type [Markdig.Markdown] is available afterwards.

The problem is that I am not able to create a Markdig object. New-Object Markdig.Markdown fails with error message New-Object : A constructor was not found. Cannot find an appropriate constructor for type Markdig.Markdown.

[Markdig.Markdown].GetConstructor() says Cannot find an overload for "GetConstructor" and the argument count: "0".. It seems that Markdig.Markdown doesn't provide usable constructors.

Please provide a hint or an example for how to use Markdig from PowerShell. At the end I want to develop a PowerShell module that encapsulates Markdig with appropriate PowerShell advanced functions.

Originally created by @datenschieber on GitHub (Jan 18, 2018). I am trying to use Markdig from PowerShell. `Addtype .\Markdig.dll` runs without problems. The type `[Markdig.Markdown]` is available afterwards. The problem is that I am not able to create a Markdig object. `New-Object Markdig.Markdown` fails with error message `New-Object : A constructor was not found. Cannot find an appropriate constructor for type Markdig.Markdown.` `[Markdig.Markdown].GetConstructor()` says `Cannot find an overload for "GetConstructor" and the argument count: "0".`. It seems that Markdig.Markdown doesn't provide usable constructors. Please provide a hint or an example for how to use Markdig from PowerShell. At the end I want to develop a PowerShell module that encapsulates Markdig with appropriate PowerShell advanced functions.
claunia added the question label 2026-01-29 14:29:42 +00:00
Author
Owner

@xoofx commented on GitHub (Jan 18, 2018):

[Markdig.Markdown].GetConstructor() says Cannot find an overload for "GetConstructor" and the argument count: "0".. It seems that Markdig.Markdown doesn't provide usable constructors.
Please provide a hint or an example for how to use Markdig from PowerShell. At the end I want to develop a PowerShell module that encapsulates Markdig with appropriate PowerShell advanced functions.

I barely use PowerShell so can't provide much help. But the class you are trying to use provides only static methods, so you can't create a new Mardown object obviously. Don't know the syntax in powershell but you should be able to access static methods likely.

@xoofx commented on GitHub (Jan 18, 2018): > [Markdig.Markdown].GetConstructor() says Cannot find an overload for "GetConstructor" and the argument count: "0".. It seems that Markdig.Markdown doesn't provide usable constructors. > Please provide a hint or an example for how to use Markdig from PowerShell. At the end I want to develop a PowerShell module that encapsulates Markdig with appropriate PowerShell advanced functions. I barely use PowerShell so can't provide much help. But the class you are trying to use provides only static methods, so you can't create a new Mardown object obviously. Don't know the syntax in powershell but you should be able to access static methods likely.
Author
Owner

@0xfeeddeadbeef commented on GitHub (Jan 18, 2018):

For example:

[Markdig.Markdown]::ToHtml('**Markdown** `Text`')
@0xfeeddeadbeef commented on GitHub (Jan 18, 2018): For example: ```powershell [Markdig.Markdown]::ToHtml('**Markdown** `Text`') ```
Author
Owner

@datenschieber commented on GitHub (Jan 18, 2018):

That's it! Thanks for the hint! I am not familiar with C#...

The solution is easy now: [Markdig.Markdown]::ToHtml("This is a text with some *emphasis*")

@datenschieber commented on GitHub (Jan 18, 2018): That's it! Thanks for the hint! I am not familiar with C#... The solution is easy now: `[Markdig.Markdown]::ToHtml("This is a text with some *emphasis*")`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#183