public class MarkdownLoadOptions extends LoadOptions
LoadFormat.MARKDOWN document into a Document object.
Examples:
Shows how to preserve empty line while load a document.
String mdText = MessageFormat.format("{0}Line1{0}{0}Line2{0}{0}", System.lineSeparator());
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions();
loadOptions.setPreserveEmptyLines(true);
Document doc = new Document(new ByteArrayInputStream(mdText.getBytes()), loadOptions);
Assert.assertEquals("\rLine1\r\rLine2\r\f", doc.getText());
| Constructor and Description |
|---|
MarkdownLoadOptions()
Initializes a new instance of
MarkdownLoadOptions class. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
getImportUnderlineFormatting()
Gets a boolean value indicating either to recognize a sequence of two plus characters "++" as underline text formatting.
|
boolean |
getPreserveEmptyLines()
Gets a boolean value indicating whether to preserve empty lines while load a
LoadFormat.MARKDOWN document. |
char |
getSoftLineBreakCharacter()
Gets a character value representing `soft line break`.
|
void |
setImportUnderlineFormatting(boolean value)
Sets a boolean value indicating either to recognize a sequence of two plus characters "++" as underline text formatting.
|
void |
setPreserveEmptyLines(boolean value)
Sets a boolean value indicating whether to preserve empty lines while load a
LoadFormat.MARKDOWN document. |
void |
setSoftLineBreakCharacter(char value)
Sets a character value representing `soft line break`.
|
equals, getBaseUri, getConvertMetafilesToPng, getConvertShapeToOfficeMath, getEncoding, getFontSettings, getIgnoreOleData, getLanguagePreferences, getLoadFormat, getMswVersion, getPassword, getPreserveIncludePictureField, getProgressCallback, getRecoveryMode, getResourceLoadingCallback, getTempFolder, getUpdateDirtyFields, getUseSystemLcid, getWarningCallback, setBaseUri, setConvertMetafilesToPng, setConvertShapeToOfficeMath, setEncoding, setFontSettings, setIgnoreOleData, setLoadFormat, setMswVersion, setPassword, setPreserveIncludePictureField, setProgressCallback, setRecoveryMode, setResourceLoadingCallback, setTempFolder, setUpdateDirtyFields, setUseSystemLcid, setWarningCallbackpublic MarkdownLoadOptions()
MarkdownLoadOptions class.
Remarks:
Automatically sets LoadFormat to LoadFormat.MARKDOWN.
Examples:
Shows how to preserve empty line while load a document.
String mdText = MessageFormat.format("{0}Line1{0}{0}Line2{0}{0}", System.lineSeparator());
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions();
loadOptions.setPreserveEmptyLines(true);
Document doc = new Document(new ByteArrayInputStream(mdText.getBytes()), loadOptions);
Assert.assertEquals("\rLine1\r\rLine2\r\f", doc.getText());
public boolean getPreserveEmptyLines()
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.
Examples:
Shows how to preserve empty line while load a document.
String mdText = MessageFormat.format("{0}Line1{0}{0}Line2{0}{0}", System.lineSeparator());
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions();
loadOptions.setPreserveEmptyLines(true);
Document doc = new Document(new ByteArrayInputStream(mdText.getBytes()), loadOptions);
Assert.assertEquals("\rLine1\r\rLine2\r\f", doc.getText());
LoadFormat.MARKDOWN document.public void setPreserveEmptyLines(boolean value)
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.
Examples:
Shows how to preserve empty line while load a document.
String mdText = MessageFormat.format("{0}Line1{0}{0}Line2{0}{0}", System.lineSeparator());
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions();
loadOptions.setPreserveEmptyLines(true);
Document doc = new Document(new ByteArrayInputStream(mdText.getBytes()), loadOptions);
Assert.assertEquals("\rLine1\r\rLine2\r\f", doc.getText());
value - A boolean value indicating whether to preserve empty lines while load a LoadFormat.MARKDOWN document.public boolean getImportUnderlineFormatting()
false.
Examples:
Shows how to recognize plus characters "++" as underline text formatting.
try (ByteArrayInputStream stream = new ByteArrayInputStream("++12 and B++".getBytes(StandardCharsets.US_ASCII)))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions(); { loadOptions.setImportUnderlineFormatting(true); }
Document doc = new Document(stream, loadOptions);
Paragraph para = (Paragraph)doc.getChild(NodeType.PARAGRAPH, 0, true);
Assert.assertEquals(Underline.SINGLE, para.getRuns().get(0).getFont().getUnderline());
loadOptions = new MarkdownLoadOptions(); { loadOptions.setImportUnderlineFormatting(false); }
doc = new Document(stream, loadOptions);
para = (Paragraph)doc.getChild(NodeType.PARAGRAPH, 0, true);
Assert.assertEquals(Underline.NONE, para.getRuns().get(0).getFont().getUnderline());
}
public void setImportUnderlineFormatting(boolean value)
false.
Examples:
Shows how to recognize plus characters "++" as underline text formatting.
try (ByteArrayInputStream stream = new ByteArrayInputStream("++12 and B++".getBytes(StandardCharsets.US_ASCII)))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions(); { loadOptions.setImportUnderlineFormatting(true); }
Document doc = new Document(stream, loadOptions);
Paragraph para = (Paragraph)doc.getChild(NodeType.PARAGRAPH, 0, true);
Assert.assertEquals(Underline.SINGLE, para.getRuns().get(0).getFont().getUnderline());
loadOptions = new MarkdownLoadOptions(); { loadOptions.setImportUnderlineFormatting(false); }
doc = new Document(stream, loadOptions);
para = (Paragraph)doc.getChild(NodeType.PARAGRAPH, 0, true);
Assert.assertEquals(Underline.NONE, para.getRuns().get(0).getFont().getUnderline());
}
value - A boolean value indicating either to recognize a sequence of two plus characters "++" as underline text formatting.public char getSoftLineBreakCharacter()
SPACE (U+0020).
Remarks:
Note, setting this option to ControlChar.LINE_BREAK_CHAR allows you to load soft line breaks as hard line breaks.
Examples:
Shows how to set soft line break character.
try (ByteArrayInputStream stream = new ByteArrayInputStream("line1\nline2".getBytes(StandardCharsets.UTF_8)))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions();
loadOptions.setSoftLineBreakCharacter(ControlChar.LINE_BREAK_CHAR);
Document doc = new Document(stream, loadOptions);
Assert.assertEquals("line1line2", doc.getText().trim());
}
public void setSoftLineBreakCharacter(char value)
SPACE (U+0020).
Remarks:
Note, setting this option to ControlChar.LINE_BREAK_CHAR allows you to load soft line breaks as hard line breaks.
Examples:
Shows how to set soft line break character.
try (ByteArrayInputStream stream = new ByteArrayInputStream("line1\nline2".getBytes(StandardCharsets.UTF_8)))
{
MarkdownLoadOptions loadOptions = new MarkdownLoadOptions();
loadOptions.setSoftLineBreakCharacter(ControlChar.LINE_BREAK_CHAR);
Document doc = new Document(stream, loadOptions);
Assert.assertEquals("line1line2", doc.getText().trim());
}
value - A character value representing `soft line break`.