Class MarkdownParser

java.lang.Object
software.bluelib.markdown.MarkdownParser

public class MarkdownParser extends Object
A class responsible for parsing and formatting Markdown into Minecraft's Component.

This class processes text components and applies Markdown-style formatting (Bold, Italic, Strikethrough, Underline, Spoiler, Hyperlink, Color, CopyToClipboard) to the text. The formatting is controlled globally or individually through the MarkdownParser.EnableMarkdownFor and MarkdownParser.DisableMarkdownFor inner classes.

Purpose: This class provides a utility for parsing and applying Markdown formatting in Minecraft chat messages.
When: This class is used when a message needs to be formatted with Markdown syntax.
Where: The class is invoked in various components where text formatting is required, typically in chat rendering or message construction.
Additional Info: The formatting can be enabled or disabled globally or selectively for specific features like bold or italic. The settings are managed via the MarkdownParser.EnableMarkdownFor and MarkdownParser.DisableMarkdownFor classes.

Key Methods:
Since:
1.1.0
See Also:
  • Constructor Details

    • MarkdownParser

      public MarkdownParser()
  • Method Details

    • parseMarkdown

      public static net.minecraft.network.chat.MutableComponent parseMarkdown(net.minecraft.network.chat.Component pMessage)
      Parses and applies Markdown formatting to a given Component message.

      Purpose: To parse and apply Markdown formatting to a given message component.
      When: Called when a component is to be formatted with Markdown styles.
      Where: This method is invoked in various places where a text message is being processed for display.
      Additional Info: The method checks if global Markdown formatting is enabled and applies the relevant formats like bold, italic, etc.

      Parameters:
      pMessage - Component - The message component containing the text to format.
      Returns:
      A MutableComponent with the Markdown formatting applied.
      Since:
      1.1.0
      See Also:
    • enableMarkdown

      public static void enableMarkdown()
      Enables global Markdown formatting.

      Purpose: To enable global Markdown formatting for all messages.
      When: Called when global Markdown formatting needs to be enabled.
      Where: This method is typically called during initialization or configuration of the Markdown settings.
      Additional Info: Enabling global formatting will allow the system to apply all Markdown features like bold, italic, etc.

      Since:
      1.1.0
      See Also:
    • disableMarkdown

      public static void disableMarkdown()
      Disables global Markdown formatting.

      Purpose: To disable global Markdown formatting for all messages.
      When: Called when global Markdown formatting should be disabled.
      Where: This method is typically invoked when the user wants to prevent any Markdown formatting from being applied.
      Additional Info: Disabling global formatting ensures no Markdown styles (e.g., bold, italic) are applied to any messages.

      Since:
      1.1.0
      See Also:
    • enableMarkdownFor

      public static MarkdownParser.EnableMarkdownFor enableMarkdownFor()
      Returns a new instance of MarkdownParser.EnableMarkdownFor to enable Markdown for specific formats.

      Purpose: To allow selective enabling of specific Markdown features.
      When: Called when specific Markdown features (e.g., bold, italic) need to be enabled.
      Where: Typically invoked in settings or configuration code to modify Markdown options.
      Additional Info: This method returns an instance of MarkdownParser.EnableMarkdownFor, which can be used for method chaining to enable various Markdown features.

      Returns:
      A new MarkdownParser.EnableMarkdownFor instance.
      Since:
      1.1.0
      See Also:
    • disableMarkdownFor

      public static MarkdownParser.DisableMarkdownFor disableMarkdownFor()
      Returns a new instance of MarkdownParser.DisableMarkdownFor to disable Markdown for specific formats.

      Purpose: To allow selective disabling of specific Markdown features.
      When: Called when specific Markdown features (e.g., bold, italic) need to be disabled.
      Where: Typically invoked in settings or configuration code to modify Markdown options.
      Additional Info: This method returns an instance of MarkdownParser.DisableMarkdownFor, which can be used for method chaining to disable various Markdown features.

      Returns:
      A new MarkdownParser.DisableMarkdownFor instance.
      Since:
      1.1.0
      See Also: