Class Italic
Purpose: This class applies italic formatting to text within markdown syntax.
When: The italic formatting 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 isItalicEnabled flag.
Key Methods:
appendFormattedText(String, Style, MutableComponent)- Appends the formatted text with italic style to the result component.isFeatureEnabled()- Checks if the italic feature is enabled.getFeatureName()- Gets the feature's name.setPrefix(String)- Updates the prefix for italic formatting.setSuffix(String)- Updates the suffix for italic formatting.getPrefix()- Retrieves the current prefix for italic formatting.getSuffix()- Retrieves the current suffix for italic formatting.isItalicEnabled()- Retrieves whether italic formatting is enabled.
- Since:
- 1.1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic BooleanFlag that determines whether the italic feature is enabled.protected static StringDefault prefix for italic formatting.protected static StringDefault suffix for italic formatting.Fields inherited from class software.bluelib.markdown.MarkdownFeature
prefix, suffix -
Constructor Summary
ConstructorsConstructorDescriptionItalic()Constructor that initializes the prefix and suffix for the italic 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 italic style to the result component.protected StringGets the feature's name.static StringRetrieves the current prefix for italic formatting.static StringRetrieves the current suffix for italic formatting.protected booleanChecks if the italic feature is enabled.static booleanChecks if the italic formatting is enabled.static voidSets the prefix for italic formatting.static voidsetPrefixSuffix(String pPrefix, String pSuffix) Sets the prefix and suffix used for italic formatting.static voidSets the suffix for italic formatting.Methods inherited from class software.bluelib.markdown.MarkdownFeature
appendUnstyledText, apply, processComponentText, processComponentTextWithFormatting, processSiblings, processSiblingsWithFormatting
-
Field Details
-
Prefix
Default prefix for italic formatting.Purpose: This variable stores the default prefix for applying italic formatting.
When: It is used when checking for the start of an italic 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 italic formatting.Purpose: This variable stores the default suffix for applying italic formatting.
When: It is used when checking for the end of an italic 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:
-
isItalicEnabled
Flag that determines whether the italic feature is enabled.Purpose: This variable holds the state of the italic feature (enabled or disabled).
When: It is checked whenever the markdown text is processed to determine whether italic should be applied.
Where: It is used in theisFeatureEnabled()andisItalicEnabled()methods.
Additional Info: This feature can be enabled or disabled globally through this flag.
- Since:
- 1.1.0
- See Also:
-
-
Constructor Details
-
Italic
public Italic()Constructor that initializes the prefix and suffix for the italic feature.Purpose: This constructor sets the default prefix and suffix values for the italic formatting.
When: It is invoked when creating an instance of theItalicclass.
Where: Executed within theItalicconstructor.
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 italic style to the result component.Purpose: This method takes the provided text and applies the italic style, then appends it to the result.
When: Called when processing a markdown string with italic syntax.
Where: Executed inMarkdownFeature.processComponentTextWithFormatting(String, Style, MutableComponent, java.util.regex.Pattern).
Additional Info: The text is wrapped with a style that enables italic formatting.
- Overrides:
appendFormattedTextin classMarkdownFeature- Parameters:
pText- The text to be formatted with the italic effect.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 italic feature is enabled.Purpose: Determines whether the italic feature is active based on the
isItalicEnabledflag.
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 throughisItalicEnabled.
- Specified by:
isFeatureEnabledin classMarkdownFeature- Returns:
trueif the italic 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 "Italic".
- Since:
- 1.6.0
- See Also:
-
setPrefixSuffix
Sets the prefix and suffix used for italic formatting.Purpose: This method allows the user to set both the prefix and suffix for italic 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 theItalicfeature.
- Parameters:
pPrefix- The new prefix for italic formatting.pSuffix- The new suffix for italic formatting.- Since:
- 1.2.0
- See Also:
-
setPrefix
Sets the prefix for italic formatting.Purpose: This method sets a new prefix for the italic formatting.
When: Called when a new prefix is desired.
Where: Executed in code where customization is needed.
Additional Info: Changes only the prefix used for italic formatting.
- Parameters:
pPrefix- The new prefix for italic formatting.- Since:
- 1.2.0
- See Also:
-
setSuffix
Sets the suffix for italic formatting.Purpose: This method sets a new suffix for the italic formatting.
When: Called when a new suffix is needed.
Where: Executed when customization is desired.
Additional Info: Changes only the suffix used for italic formatting.
- Parameters:
pSuffix- The new suffix for italic formatting.- Since:
- 1.2.0
- See Also:
-
getPrefix
Retrieves the current prefix for italic formatting.Purpose: This method returns the current prefix used for italic formatting.
When: Called when the current prefix value is needed.
Where: Executed when the prefix is required for formatting.
Additional Info: This value can be customized throughsetPrefix(String).
- Returns:
- The current prefix used for italic formatting.
- Since:
- 1.2.0
- See Also:
-
getSuffix
Retrieves the current suffix for italic formatting.Purpose: This method returns the current suffix used for italic formatting.
When: Called when the current suffix value is needed.
Where: Executed when the suffix is required for formatting.
Additional Info: This value can be customized throughsetSuffix(String).
- Returns:
- The current suffix used for italic formatting.
- Since:
- 1.2.0
- See Also:
-
isItalicEnabled
public static boolean isItalicEnabled()Checks if the italic formatting is enabled.Purpose: This method checks whether italic formatting is enabled or disabled.
When: Called when determining whether to apply italic formatting.
Where: Executed in logic that processes markdown.
Additional Info: It uses the global flagisItalicEnabledto determine the state.
- Returns:
trueif italic formatting is enabled,falseotherwise.- Since:
- 1.2.0
- See Also:
-