/PandocNet

Conversion of documents in .net via Pandoc.

Primary LanguageC#MIT LicenseMIT

PandocNet

Build status NuGet Status

Conversion of documents via Pandoc. Wraps pandoc.exe using CliWrap and provides strong typed options for document formats.

See Milestones for release notes.

NuGet package

https://nuget.org/packages/Pandoc/

Usage

Pandoc Path

By default pandoc.exe is expected to be accessible in the current environmenst Path.

Installing Pandoc.

This can be changed:

var engine = new PandocEngine(@"D:\Tools\pandoc.exe");

snippet source | anchor

Text

var html = await PandocInstance.ConvertToText<CommonMarkIn, HtmlOut>("*text*");

snippet source | anchor

Streams

await using var inStream = File.OpenRead("sample.md");
await using var outStream = File.OpenWrite("output.html");
await PandocInstance.Convert<CommonMarkIn, HtmlOut>(inStream, outStream);

snippet source | anchor

Files

await PandocInstance.Convert<CommonMarkIn, HtmlOut>("sample.md", "output.html");

snippet source | anchor

Custom Options

var html = await PandocInstance.ConvertToText(
    """

    # Heading1

    text

    ## Heading2

    text

    """,
    new CommonMarkIn
    {
        ShiftHeadingLevelBy = 2
    },
    new HtmlOut
    {
        NumberOffsets = new List<int> {3}
    });

snippet source | anchor

Icon

Pan Flute designed by Creaticca Creative Agency from The Noun Project.