This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
PandocNet is a .NET wrapper library for Pandoc (the universal document converter). It provides strongly-typed C# option classes for each input/output format and uses the standard System.Diagnostics.Process API for process execution. Published as the Pandoc NuGet package.
# Build (from src/)
dotnet build src/PandocNet.slnx
# Run all tests (requires pandoc installed on PATH)
dotnet test src/Tests
# Run a single test
dotnet test src/Tests --filter "Name~TextMethod"Pandoc must be installed locally (choco install pandoc on Windows). Tests target net9.0; the library multi-targets net7.0/net8.0/net9.0.
- C# preview language version (currently C# 13)
TreatWarningsAsErrorsis enabled — all warnings are build errorsEnforceCodeStyleInBuildis enabled — code style violations fail the build- Nullable reference types are enabled
Two entry points to the same engine:
PandocInstance— static facade wrapping a singletonPandocEnginePandocEngine— instantiable class; accepts optional custom pandoc path
Core conversion flow:
- Caller invokes
Convert<TIn, TOut>()(stream/file output) orConvertToText<TIn, TOut>()(string output), with generic type params being format option classes (e.g.CommonMarkIn,HtmlOut) - Engine collects CLI arguments from the option objects via
GetArguments()virtual methods System.Diagnostics.Processexecutes pandoc with piped stdin/stdout (stdin source streamed viaInput.WriteTo, stdout target streamed viaOutput.ReadFrom)- Exit code is checked against
ErrorCodesmapping; result returned asResultorStringResult
Input/Output abstraction:
Input— polymorphic source (file path, URL, stream, byte[], or text content); auto-detects type. Implicit operators fromstring,Stream,byte[].Output— polymorphic target (file path, stream, or StringBuilder). Implicit operators fromstring,Stream,StringBuilder.
Options hierarchy:
Options— global pandoc options (data directory, defaults file, log file)InOptions(abstract) — base for all 39 input format classes. Subclasses overrideFormatproperty. Located insrc/PandocNet/Input/.OutOptions(abstract) — base for all 63 output format classes. Subclasses overrideFormatproperty. Located insrc/PandocNet/Output/.- Format-specific subclasses add typed properties for that format's CLI flags (e.g.
HtmlOuthas section numbering, math rendering options)
- Framework: NUnit with Verify.NUnit (snapshot/approval testing)
- Verified output files:
Tests.*.verified.*with platform-specific variants (Windows vs Linux line endings) - Tests are non-parallelizable (set in
ModuleInitializer.cs) Samples.cscontains code snippets extracted into the README via MarkdownSnippets- The
InputsAndOutputstest generatesinput.include.mdandoutput.include.mddocumentation files
- AppVeyor builds on push (installs pandoc via Chocolatey, runs tests, publishes NuGet)
- GitHub Actions: auto-updates docs on push (
on-push-do-docs.yml), auto-merges Dependabot PRs, manages milestone-based releases