Class InlineElement
- Since:
- 0.0.11
- Author:
- Thomas Kwashnak
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected <T> T
checkType
(T object) Checks the type of a passed object.boolean
Whether a new line should be added after inserting the element into a document.boolean
Whether the element requires at least one\n
before printing itself in a documentMethods inherited from class org.tealeaf.javamarkdown.MarkdownElement
asString, asString, toAppendable, toString, toWriter
-
Constructor Details
-
InlineElement
public InlineElement()
-
-
Method Details
-
checkType
protected <T> T checkType(T object) Checks the type of a passed object. This method is specific to each element and throws an
IllegalContentsException
if the passed object cannot be put in as a content of that element. This prevents instances such as nested tables, where a table is put inside another table. If such feature is necessary, using theMarkdownElement.toString()
of any markdown element will force it to be accepted in any spotThrows
IllegalContentsException
if object is an instance of theStructure
classThrows
IllegalContentsException
if object is instance of the same class (such as anItalic
within anItalic
)- Specified by:
checkType
in classMarkdownElement
- Type Parameters:
T
- The type of the item- Parameters:
object
- The item to check it's class- Returns:
- That item if it is not an instance of any illegal types
- Since:
- 0.0.11
-
requiresNewlineAfter
public boolean requiresNewlineAfter()Whether a new line should be added after inserting the element into a document. This is particularly useful for structures that need to have a newline after it gets rendered
For example, if some text was printed immediately after a list, it would render as:
- item 1 - item 2 - item 3some text
Thus, by requiring a new line after the element is rendered, we get the following output instead:
- item 1 - item 2 - item 3 some text
This method is natively used in
MarkdownWriter.appendMarkdownElement(MarkdownElement)
to handle adding newlines when necessary- Specified by:
requiresNewlineAfter
in classMarkdownElement
- Returns:
- false
- Since:
- 0.0.19
-
requiresNewlineBefore
public boolean requiresNewlineBefore()Whether the element requires at least one
\n
before printing itself in a documentIn instances such as in-line elements (like
Bold
), this would returnfalse
because bolds can be inserted directly in-line. However, in instances such asNumberedList
, it would be required that there is a new line to prevent the followingSome sentence - item 1 - item 2 - item 3
and instead print the following
Some sentence - item 1 - item 2
This method is natively used in
MarkdownWriter.appendMarkdownElement(MarkdownElement)
to handle adding newlines when necessary- Specified by:
requiresNewlineBefore
in classMarkdownElement
- Returns:
- false
- Since:
- 0.0.19
-