Interface IMarkdownToDocxConverter
- Namespace
- DocToolkit.Extensions.DependencyInjection
- Assembly
- DocToolkit.Extensions.DependencyInjection.dll
Converts Markdown to a Word (.docx) package, completing the round trip IDocxToMarkdownConverter opens. Registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?).
public interface IMarkdownToDocxConverter
Remarks
Nothing here reaches the network or the disk. A remote image reference becomes a
hyperlink rather than a fetch, and a local file reference is refused - reading a path out of
untrusted document content would let the document choose which file gets embedded in the
output. data: images are inlined, since they carry their own bytes.
There is no Stream source overload, here or on the static API: the input is a
string rather than a document, so a caller holding bytes decides their own
encoding.
Methods
Convert(string)
Converts markdown to a .docx package.
byte[] Convert(string markdown)
Parameters
markdownstring
Returns
- byte[]
Exceptions
- ArgumentNullException
markdownis null.- DocumentConversionException
It could not be converted.
ConvertAsync(string, Stream, CancellationToken)
Converts markdown and writes the .docx to destination,
which is written but neither disposed, closed nor sought.
Task ConvertAsync(string markdown, Stream destination, CancellationToken ct = default)
Parameters
markdownstringdestinationStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
Either argument is null.
- ArgumentException
destinationis not writable.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
It could not be converted.
ConvertWithReport(string)
Converts markdown and reports what the conversion could not carry
across. Convert(string) produces the same document.
ConversionResult<byte[]> ConvertWithReport(string markdown)
Parameters
markdownstring
Returns
Exceptions
- ArgumentNullException
markdownis null.- DocumentConversionException
It could not be converted.