Class MarkdownLoadOptions
Namespace: Aspose.Words.Loading
Assembly: Aspose.Words.dll (25.12.0)
Allows to specify additional options when loading Aspose.Words.LoadFormat.Markdown document into a Aspose.Words.Document object.
public class MarkdownLoadOptions : LoadOptionsInheritance
object ← LoadOptions ← MarkdownLoadOptions
Inherited Members
LoadOptions.Equals(object) , LoadOptions.LoadFormat , LoadOptions.Password , LoadOptions.BaseUri , LoadOptions.Encoding , LoadOptions.ResourceLoadingCallback , LoadOptions.WarningCallback , LoadOptions.ProgressCallback , LoadOptions.PreserveIncludePictureField , LoadOptions.ConvertShapeToOfficeMath , LoadOptions.FontSettings , LoadOptions.TempFolder , LoadOptions.ConvertMetafilesToPng , LoadOptions.MswVersion , LoadOptions.UpdateDirtyFields , LoadOptions.IgnoreOleData , LoadOptions.UseSystemLcid , LoadOptions.LanguagePreferences , LoadOptions.RecoveryMode , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Shows how to preserve empty line while load a document.
string mdText = $"{Environment.NewLine}Line1{Environment.NewLine}{Environment.NewLine}Line2{Environment.NewLine}{Environment.NewLine}";
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(mdText)))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions() { PreserveEmptyLines = true };
Document doc = new Document(stream, loadOptions);
Assert.That(doc.GetText(), Is.EqualTo("\rLine1\r\rLine2\r\f"));
}Constructors
MarkdownLoadOptions()
Initializes a new instance of Aspose.Words.Loading.MarkdownLoadOptions class.
public MarkdownLoadOptions()Examples
Shows how to preserve empty line while load a document.
string mdText = $"{Environment.NewLine}Line1{Environment.NewLine}{Environment.NewLine}Line2{Environment.NewLine}{Environment.NewLine}";
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(mdText)))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions() { PreserveEmptyLines = true };
Document doc = new Document(stream, loadOptions);
Assert.That(doc.GetText(), Is.EqualTo("\rLine1\r\rLine2\r\f"));
}Remarks
Automatically sets Aspose.Words.LoadFormat to Aspose.Words.LoadFormat.Markdown.
Properties
ImportUnderlineFormatting
Gets or sets a boolean value indicating either to recognize a sequence
of two plus characters “++” as underline text formatting.
The default value is false.
public bool ImportUnderlineFormatting { get; set; }Property Value
Examples
Shows how to recognize plus characters “++” as underline text formatting.
using (MemoryStream stream = new MemoryStream(Encoding.ASCII.GetBytes("++12 and B++")))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions() { ImportUnderlineFormatting = true };
Document doc = new Document(stream, loadOptions);
Paragraph para = (Paragraph)doc.GetChild(NodeType.Paragraph, 0, true);
Assert.That(para.Runs[0].Font.Underline, Is.EqualTo(Underline.Single));
loadOptions = new MarkdownLoadOptions() { ImportUnderlineFormatting = false };
doc = new Document(stream, loadOptions);
para = (Paragraph)doc.GetChild(NodeType.Paragraph, 0, true);
Assert.That(para.Runs[0].Font.Underline, Is.EqualTo(Underline.None));
}PreserveEmptyLines
Gets or sets a boolean value indicating whether to preserve empty lines while load a Aspose.Words.LoadFormat.Markdown document.
The default value is false.
Normally, empty lines between block-level elements in Markdown are ignored. Empty lines at the beginning and end of the document are also ignored. This option allows to import such empty lines.
public bool PreserveEmptyLines { get; set; }Property Value
Examples
Shows how to preserve empty line while load a document.
string mdText = $"{Environment.NewLine}Line1{Environment.NewLine}{Environment.NewLine}Line2{Environment.NewLine}{Environment.NewLine}";
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(mdText)))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions() { PreserveEmptyLines = true };
Document doc = new Document(stream, loadOptions);
Assert.That(doc.GetText(), Is.EqualTo("\rLine1\r\rLine2\r\f"));
}SoftLineBreakCharacter
Gets or sets a character value representing soft line break.
The default value is SPACE (U+0020).
public char SoftLineBreakCharacter { get; set; }Property Value
Examples
Shows how to set soft line break character.
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes("line1\nline2")))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions();
loadOptions.SoftLineBreakCharacter = ControlChar.LineBreakChar;
Document doc = new Document(stream, loadOptions);
Assert.That(doc.GetText().Trim(), Is.EqualTo("line1\u000bline2"));
}Remarks
Note, setting this option to Aspose.Words.ControlChar.LineBreakChar allows you to load soft line breaks as hard line breaks.