HtmlToText Class

An HTML to plain text converter.

Definition

Namespace: MimeKit.Text
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public class HtmlToText : TextConverter
Inheritance
Object    TextConverter    HtmlToText

Remarks

Converts HTML documents or fragments into plain text, preserving paragraphs, line breaks, headings, lists, blockquotes and preformatted text. Headings use hash prefixes, lists use bullets or decimal numbers, and quoted lines use greater-than prefixes.

Scripts, styles, titles, templates and elements with a hidden attribute are omitted. CSS is not evaluated, inline emphasis is reduced to its text, and tables are flattened without borders or column alignment. The output is plain text, not a Markdown serialization.

Output is not word-wrapped. Generated line endings use NewLine. Structural spacing at the end of the document is omitted, while explicit line breaks and preformatted whitespace are retained. The inherited header and footer are literal text.

Constructors

HtmlToText Initialize a new instance of the HtmlToText class.

Properties

DetectEncodingFromByteOrderMark Get or set whether the encoding of the input is detected from the byte order mark or determined by the InputEncoding property.
(Inherited from TextConverter)
Footer Get or set the text that will be appended to the end of the output.
(Inherited from TextConverter)
Header Get or set text that will be prepended to the beginning of the output.
(Inherited from TextConverter)
InputEncoding Get or set the input encoding.
(Inherited from TextConverter)
InputFormat Get the input format.
(Overrides TextConverterInputFormat)
InputStreamBufferSize Get or set the size of the input stream buffer.
(Inherited from TextConverter)
MaxElementDepth Get or set the maximum element depth.
MaxInputLength Get or set the maximum input length.
MaxOutputLength Get or set the maximum output length.
OutputEncoding Get or set the output encoding.
(Inherited from TextConverter)
OutputFormat Get the output format.
(Overrides TextConverterOutputFormat)
OutputImageAltText Get or set whether image alternative text should be included in the output.
OutputLinkUrls Get or set whether link destinations should be included in the output.
OutputStreamBufferSize Get or set the size of the output stream buffer.
(Inherited from TextConverter)

Methods

Convert(String) Convert text from the InputFormat to the OutputFormat.
(Inherited from TextConverter)
Convert(Stream, Stream) Convert the contents of source from the InputFormat to the OutputFormat and writes the resulting text to destination.
(Inherited from TextConverter)
Convert(Stream, TextWriter) Convert the contents of source from the InputFormat to the OutputFormat and uses the writer to write the resulting text.
(Inherited from TextConverter)
Convert(TextReader, TextWriter) Convert HTML to plain text.
(Overrides TextConverterConvert(TextReader, TextWriter))
Convert(TextReader, Stream) Convert the contents of reader from the InputFormat to the OutputFormat and writes the resulting text to destination.
(Inherited from TextConverter)
Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCode Serves as the default hash function.
(Inherited from Object)
GetType Gets the Type of the current instance.
(Inherited from Object)
MemberwiseClone Creates a shallow copy of the current Object.
(Inherited from Object)
ToString Returns a string that represents the current object.
(Inherited from Object)

See Also