Class Underline
Purpose: This class is responsible for adding underline formatting to text within markdown syntax.
When: The underline is applied when the text is surrounded by a specified prefix and suffix.
Where: Executed within the MarkdownParser.parseMarkdown(Component) method when the feature is enabled.
Additional Info: The default prefix and suffix are both set to "__". The feature is controlled by the isUnderlineEnabled flag.
Key Methods:
appendFormattedText(String, Style, MutableComponent)- Applies the Underline formatting to the provided text.isFeatureEnabled()- Checks if the Underline feature is enabled.getFeatureName()- Retrieves the name of the Underline feature.setPrefixSuffix(String, String)- Updates the prefix and suffix used for Underline formatting.setPrefix(String)- Updates the prefix used for Underline formatting.setSuffix(String)- Updates the suffix used for Underline formatting.getPrefix()- Retrieves the current prefix used for Underline formatting.getSuffix()- Retrieves the current suffix used for Underline formatting.isUnderlineEnabled()- Retrieves whether Underline formatting is enabled.
- Since:
- 1.1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic BooleanFlag that determines whether the underline feature is enabled.protected static StringDefault prefix for underline formatting.protected static StringDefault suffix for underline formatting.Fields inherited from class software.bluelib.markdown.MarkdownFeature
prefix, suffix -
Constructor Summary
ConstructorsConstructorDescriptionConstructor that initializes the prefix and suffix for the underline feature. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendFormattedText(String pText, net.minecraft.network.chat.Style pOriginalStyle, net.minecraft.network.chat.MutableComponent pResult) Appends the formatted text with the underline style to the result component.protected StringGets the feature's name.static StringGets the prefix used for underline formatting.static StringGets the suffix used for underline formatting.protected booleanChecks if the underline feature is enabled.static BooleanChecks if the underline feature is enabled.static voidSets the prefix used for underline formatting.static voidsetPrefixSuffix(String pPrefix, String pSuffix) Sets the prefix and suffix used for underline formatting.static voidSets the suffix used for underline formatting.Methods inherited from class software.bluelib.markdown.MarkdownFeature
appendUnstyledText, apply, processComponentText, processComponentTextWithFormatting, processSiblings, processSiblingsWithFormatting
-
Field Details
-
Prefix
Default prefix for underline formatting.Purpose: This variable stores the default prefix for applying underline formatting.
When: It is used when checking for the start of an underline formatted section.
Where: Used in theMarkdownFeature.prefixandMarkdownFeature.suffixlogic.
Additional Info: The default value is "__", but it can be modified usingsetPrefix(String)andsetSuffix(String).
- Since:
- 1.2.0
- See Also:
-
Suffix
Default suffix for underline formatting.Purpose: This variable stores the default suffix for applying underline formatting.
When: It is used when checking for the end of an underline formatted section.
Where: Used in theMarkdownFeature.prefixandMarkdownFeature.suffixlogic.
Additional Info: The default value is "__", but it can be modified usingsetPrefix(String)andsetSuffix(String).
- Since:
- 1.2.0
- See Also:
-
isUnderlineEnabled
Flag that determines whether the underline feature is enabled.Purpose: This variable holds the state of the underline feature (enabled or disabled).
When: It is checked whenever the markdown text is processed to determine whether the underline should be applied.
Where: It is used in theisFeatureEnabled()andisUnderlineEnabled()methods.
Additional Info: This feature can be enabled or disabled globally through this flag.
- Since:
- 1.1.0
- See Also:
-
-
Constructor Details
-
Underline
public Underline()Constructor that initializes the prefix and suffix for the underline feature.Purpose: This constructor sets the default prefix and suffix values for the underline formatting.
When: It is invoked when creating an instance of theUnderlineclass.
Where: Executed within theUnderlineconstructor.
Additional Info: The default prefix and suffix are both set to "__".
- Since:
- 1.1.0
- See Also:
-
-
Method Details
-
appendFormattedText
protected void appendFormattedText(String pText, net.minecraft.network.chat.Style pOriginalStyle, net.minecraft.network.chat.MutableComponent pResult) Appends the formatted text with the underline style to the result component.Purpose: This method takes the provided text and applies the underline style, then appends it to the result.
When: Called when processing a markdown string with underline syntax.
Where: Executed inMarkdownFeature.processComponentTextWithFormatting(String, Style, MutableComponent, java.util.regex.Pattern).
Additional Info: The text is wrapped with a style that enables underlining.
- Overrides:
appendFormattedTextin classMarkdownFeature- Parameters:
pText- The text to be formatted with underline.pOriginalStyle- The original style applied to the text.pResult- The mutable component that the formatted text will be appended to.- Since:
- 1.6.0
- See Also:
-
isFeatureEnabled
protected boolean isFeatureEnabled()Checks if the underline feature is enabled.Purpose: Determines whether the underline feature is active based on the
isUnderlineEnabledflag.
When: Called before processing the text to check if the feature should be applied.
Where: Executed inMarkdownFeature.apply(MutableComponent).
Additional Info: This flag can be changed throughisUnderlineEnabled.
- Specified by:
isFeatureEnabledin classMarkdownFeature- Returns:
trueif underline is enabled,falseotherwise.- Since:
- 1.6.0
- See Also:
-
getFeatureName
Gets the feature's name.Purpose: Provides the name of this Markdown feature for display purposes.
When: It is called to return the feature name in logs or debugging output.
Where: Used in theMarkdownFeature.apply(MutableComponent).
Additional Info: The name is returned as a simple string.
- Specified by:
getFeatureNamein classMarkdownFeature- Returns:
- The name of the feature, which is "Underline".
- Since:
- 1.6.0
- See Also:
-
setPrefixSuffix
Sets the prefix and suffix used for underline formatting.Purpose: This method allows the user to set both the prefix and suffix for underline formatting.
When: It is called to customize the prefix and suffix.
Where: Can be invoked from any class or method.
Additional Info: The updated prefix and suffix will affect all instances of theUnderlinefeature.
- Parameters:
pPrefix- The new prefix for underline.pSuffix- The new suffix for underline.- Since:
- 1.2.0
- See Also:
-
setPrefix
Sets the prefix used for underline formatting.Purpose: This method allows the user to set the prefix for underline formatting.
When: It is called to customize the prefix.
Where: Can be invoked from any class or method.
Additional Info: The updated prefix will affect all instances of theUnderlinefeature.
- Parameters:
pPrefix- The new prefix for underline.- Since:
- 1.2.0
- See Also:
-
setSuffix
Sets the suffix used for underline formatting.Purpose: This method allows the user to set the suffix for underline formatting.
When: It is called to customize the suffix.
Where: Can be invoked from any class or method.
Additional Info: The updated suffix will affect all instances of theUnderlinefeature.
- Parameters:
pSuffix- The new suffix for underline.- Since:
- 1.2.0
- See Also:
-
getPrefix
Gets the prefix used for underline formatting.Purpose: This method returns the current prefix used for underline formatting.
When: It is called to retrieve the prefix.
Where: Can be invoked from any class or method.
Additional Info: This returns the default or custom prefix depending on prior settings.
- Returns:
- The current prefix used for underline.
- Since:
- 1.2.0
- See Also:
-
getSuffix
Gets the suffix used for underline formatting.Purpose: This method returns the current suffix used for underline formatting.
When: It is called to retrieve the suffix.
Where: Can be invoked from any class or method.
Additional Info: This returns the default or custom suffix depending on prior settings.
- Returns:
- The current suffix used for underline.
- Since:
- 1.2.0
- See Also:
-
isUnderlineEnabled
Checks if the underline feature is enabled.Purpose: This method returns the current state of the underline feature (enabled or disabled).
When: It is called to check if the underline feature is enabled.
Where: Can be invoked from any class or method.
Additional Info: This method reflects the current state of theisUnderlineEnabledflag.
- Returns:
trueif the underline feature is enabled,falseotherwise.- Since:
- 1.2.0
- See Also:
-