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