Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/simoncropp/pandocnet

Conversion of documents in .net via Pandoc.
https://github.com/simoncropp/pandocnet

documentconversion pandoc

Last synced: 1 day ago
JSON representation

Conversion of documents in .net via Pandoc.

Awesome Lists containing this project

README

        

# PandocNet

[![Build status](https://ci.appveyor.com/api/projects/status/naxouwk164twkgn3?svg=true)](https://ci.appveyor.com/project/SimonCropp/PandocNet)
[![NuGet Status](https://img.shields.io/nuget/v/Pandoc.svg)](https://www.nuget.org/packages/Pandoc/)

Conversion of documents via [Pandoc](https://pandoc.org/). Wraps pandoc.exe using [CliWrap](https://github.com/Tyrrrz/CliWrap) and provides strong typed options for document formats.

**See [Milestones](../../milestones?state=closed) 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](https://pandoc.org/installing.html).

This can be changed:


```cs
var engine = new PandocEngine(@"D:\Tools\pandoc.exe");
```
snippet source | anchor

### Text


```cs
var html = await PandocInstance.ConvertToText("*text*");
```
snippet source | anchor

### Streams


```cs
await using var inStream = File.OpenRead("sample.md");
await using var outStream = File.OpenWrite("output.html");
await PandocInstance.Convert(inStream, outStream);
```
snippet source | anchor

### Files


```cs
await PandocInstance.Convert("sample.md", "output.html");
```
snippet source | anchor

### Custom Options


```cs
var html = await PandocInstance.ConvertToText(
"""

# Heading1

text

## Heading2

text

""",
new CommonMarkIn
{
ShiftHeadingLevelBy = 2
},
new HtmlOut
{
NumberOffsets = new List {3}
});
```
snippet source | anchor

## Icon

[Pan Flute](https://thenounproject.com/term/pan+flute/1526666/) designed by [Creaticca Creative Agency](https://thenounproject.com/creaticca/) from [The Noun Project](https://thenounproject.com/).