Classes
BadgePlugin
Mistune plugin for inline badge syntax.
Syntax:
{bdg-primary}`text` -> Primary color badg…
BadgePlugin
Mistune plugin for inline badge syntax.
Syntax:
{bdg-primary}`text` -> Primary color badge
{bdg-secondary}`text` -> Secondary/muted badge
{bdg-success}`text` -> Success/green badge
{bdg-danger}`text` -> Danger/red badge
{bdg-warning}`text` -> Warning/yellow badge
{bdg-info}`text` -> Info/blue badge
{bdg-light}`text` -> Light badge
{bdg-dark}`text` -> Dark badge
Maps to Bengal's CSS color system: bdg-primary -> badge-primary (blue) bdg-secondary -> badge-secondary (gray) bdg-success -> badge-success (green) bdg-danger -> badge-danger (red) bdg-warning -> badge-warning (yellow) bdg-info -> badge-info (blue) bdg-light -> badge-light (light gray) bdg-dark -> badge-dark (dark gray)
Compatibility: Full support for bdg-* roles.
Internal Methods 4
__init__
Initialize badge plugin.
__init__
def __init__(self) -> None
Initialize badge plugin.
__call__
Register the plugin with Mistune.
Badge substitution happens in parser.py afte…
__call__
def __call__(self, md: Any) -> Any
Register the plugin with Mistune.
Badge substitution happens in parser.py after HTML is generated. This method is required for Mistune plugin interface but does nothing.
Parameters 1
md |
Any |
Returns
Any
_substitute_badges
Substitute {bdg-color}<code>text</code> patterns with badge HTML.
Mistune conv…
_substitute_badges
def _substitute_badges(self, html: str) -> str
Substitute {bdg-color}<code>text</code> patterns with badge HTML.
Mistune convertstextto <code>text</code> before our plugin runs,
so we match the HTML pattern: {bdg-color}<code>text</code>
Parameters 1
html |
str |
HTML content that may contain badge patterns |
Returns
HTML with badge patterns replaced by badge spansstr
—
_escape_html
Escape HTML special characters in badge text.
_escape_html
def _escape_html(self, text: str) -> str
Escape HTML special characters in badge text.
Parameters 1
text |
str |
Badge text to escape |
Returns
Escaped textstr
—