Class Bold
Purpose: This class is responsible for adding bold formatting to text within markdown syntax.
When: The bold 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 isBoldEnabled flag.
Key Methods:
appendFormattedText(String, Style, MutableComponent)- Appends the formatted text with the bold style to the result component.isFeatureEnabled()- Checks if the bold feature is enabled.getFeatureName()- Gets the feature's name.setPrefixSuffix(String, String)- Updates the prefix and suffix for bold formatting.setPrefix(String)- Updates the prefix for bold formatting.setSuffix(String)- Updates the suffix for bold formatting.getPrefix()- Retrieves the current prefix for bold formatting.getSuffix()- Retrieves the current suffix for bold formatting.isBoldEnabled()- Retrieves whether bold formatting is enabled.
- Since:
- 1.1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic BooleanFlag that determines whether the bold feature is enabled.protected static StringDefault prefix for bold formatting.protected static StringDefault suffix for bold formatting.Fields inherited from class software.bluelib.markdown.MarkdownFeature
prefix, suffix -
Constructor Summary
ConstructorsConstructorDescriptionBold()Constructor that initializes the prefix and suffix for the bold 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 bold style to the result component.protected StringGets the feature's name.static StringRetrieves the current prefix for bold formatting.static StringRetrieves the current suffix for bold formatting.static BooleanRetrieves whether the bold feature is enabled.protected booleanChecks if the bold feature is enabled.static voidSets the prefix for bold formatting.static voidsetPrefixSuffix(String pPrefix, String pSuffix) Sets the prefix and suffix used for bold formatting.static voidSets the suffix for bold formatting.Methods inherited from class software.bluelib.markdown.MarkdownFeature
appendUnstyledText, apply, processComponentText, processComponentTextWithFormatting, processSiblings, processSiblingsWithFormatting
-
Field Details
-
Prefix
Default prefix for bold formatting.Purpose: This variable stores the default prefix for applying bold formatting.
When: It is used when checking for the start of a bold 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 bold formatting.Purpose: This variable stores the default suffix for applying bold formatting.
When: It is used when checking for the end of a bold 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:
-
isBoldEnabled
Flag that determines whether the bold feature is enabled.Purpose: This variable holds the state of the bold feature (enabled or disabled).
When: It is checked whenever the markdown text is processed to determine whether the bold should be applied.
Where: It is used in theisFeatureEnabled()andisBoldEnabled()methods.
Additional Info: This feature can be enabled or disabled globally through this flag.
- Since:
- 1.1.0
- See Also:
-
-
Constructor Details
-
Bold
public Bold()Constructor that initializes the prefix and suffix for the bold feature.Purpose: This constructor sets the default prefix and suffix values for the bold formatting.
When: It is invoked when creating an instance of theBoldclass.
Where: Executed within theBoldconstructor.
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 bold style to the result component.Purpose: This method takes the provided text and applies the bold style, then appends it to the result.
When: Called when processing a markdown string with bold syntax.
Where: Executed inMarkdownFeature.processComponentTextWithFormatting(String, Style, MutableComponent, java.util.regex.Pattern).
Additional Info: The text is wrapped with a style that enables bold formatting.
- Overrides:
appendFormattedTextin classMarkdownFeature- Parameters:
pText- The text to be formatted with bold.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 bold feature is enabled.Purpose: Determines whether the bold feature is active based on the
isBoldEnabledflag.
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 throughisBoldEnabled.
- Specified by:
isFeatureEnabledin classMarkdownFeature- Returns:
trueif bold 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 "Bold".
- Since:
- 1.6.0
- See Also:
-
setPrefixSuffix
Sets the prefix and suffix used for bold formatting.Purpose: This method allows the user to set both the prefix and suffix for bold 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 theBoldfeature.
- Parameters:
pPrefix- The new prefix for bold.pSuffix- The new suffix for bold.- Since:
- 1.2.0
- See Also:
-
setPrefix
Sets the prefix for bold formatting.Purpose: This method sets a new prefix for the bold formatting.
When: Called when a new prefix is desired.
Where: This method is used in thesetPrefixSuffix(String, String)method.
Additional Info: The prefix should be set before processing markdown text.
- Parameters:
pPrefix- The new prefix for bold formatting.- Since:
- 1.2.0
- See Also:
-
setSuffix
Sets the suffix for bold formatting.Purpose: This method sets a new suffix for the bold formatting.
When: Called when a new suffix is desired.
Where: This method is used in thesetPrefixSuffix(String, String)method.
Additional Info: The suffix should be set before processing markdown text.
- Parameters:
pSuffix- The new suffix for bold formatting.- Since:
- 1.2.0
- See Also:
-
getPrefix
Retrieves the current prefix for bold formatting.Purpose: This method retrieves the current prefix used for bold formatting.
When: Called when the current prefix needs to be checked.
Where: Used insetPrefix(String).
Additional Info: The value can be changed with thesetPrefix(String)method.
- Returns:
- The current prefix used for bold formatting.
- Since:
- 1.2.0
- See Also:
-
getSuffix
Retrieves the current suffix for bold formatting.Purpose: This method retrieves the current suffix used for bold formatting.
When: Called when the current suffix needs to be checked.
Where: Used insetSuffix(String).
Additional Info: The value can be changed with thesetSuffix(String)method.
- Returns:
- The current suffix used for bold formatting.
- Since:
- 1.2.0
- See Also:
-
isBoldEnabled
Retrieves whether the bold feature is enabled.Purpose: This method checks the state of the bold feature.
When: It is called to determine if bold should be applied.
Where: Used in theisFeatureEnabled()method.
Additional Info: This can be controlled by the global feature flagisBoldEnabled.
- Returns:
trueif the feature is enabled,falseotherwise.- Since:
- 1.2.0
- See Also:
-