Markdown.Encode Method
- Namespace
- Kampute.DocToolkit.Support
- Assembly
- Kampute.DocToolkit.dll
| Markdown.Encode(string, bool) | Encodes Markdown special characters in the given text. |
| Markdown.Encode(ReadOnlySpan<char>, TextWriter, bool) | Encodes Markdown special characters in the given text and writes the result to the specified TextWriter. |
Markdown.Encode(string, bool)
Encodes Markdown special characters in the given text.
public static string Encode(string text, bool atLineStart = true)Parameters
textstring- The text to encode.
atLineStartbool optional- Indicates whether the text is at the start of a line (ignoring leading whitespace).
Returns
- string
- A string with Markdown special characters escaped.
Exceptions
- ArgumentNullException
- Thrown when
textisnull.
Remarks
Markdown.Encode(ReadOnlySpan<char>, TextWriter, bool)
Encodes Markdown special characters in the given text and writes the result to the specified TextWriter.
public static void Encode(ReadOnlySpan<char> text, TextWriter output, bool atLineStart = true)Parameters
textReadOnlySpan<char>- The text to encode.
outputTextWriter- The TextWriter to write the encoded text to.
atLineStartbool optional- Indicates whether the text is at the start of a line (ignoring leading whitespace).
Exceptions
- ArgumentNullException
- Thrown when
outputisnull.
Remarks
If
atLineStart is true, the method escapes Markdown characters that have special meaning at the start of a line. Otherwise, these characters are escaped only if they are special in other contexts.Encoding behavior adjusts dynamically, treating newlines as line breaks and ignoring leading whitespace when determining whether a character appears at the start of a line.

atLineStartistrue, the method escapes Markdown characters that have special meaning at the start of a line. Otherwise, these characters are escaped only if they are special in other contexts.Encoding behavior adjusts dynamically, treating newlines as line breaks and ignoring leading whitespace when determining whether a character appears at the start of a line.