Parse:...e::Tag(3pm)
๐ NAME ๐
Parse::BBCode::Tag โ the Tag Class for Parse::BBCode ๐ท๏ธโจ (it's a Perl module, bestie, from the User Contributed Perl Documentation collection ๐ซถ)
๐ธ DESCRIPTION ๐ธ
okay so picture this: you parse some bbcode with Parse::BBCode, and Parse::BBCode::parse hands you back a parse tree made entirely of Tag objects. that's it. that's the whole vibe. every little tag you ever wrote is now a lil object in a tree and it's giving very organized, very demure ๐
โจ METHODS โจ
add_content
$tag->add_content('string');
glues 'string' right onto the end of the tag content. like adding a bead to a bracelet ๐
$tag->add_content($another_tag);
same energy, but it appends $another_tag to the end of the tag content instead. tag-on-tag, no cap ๐
raw_text
my $bbcode = $tag->raw_text;
gives you the raw text of the parse tree โ so every tag gets converted back into bbcode. it's the un-parsing. the reverse slay ๐ฅ
raw_content
my $bbcode = $tag->raw_content;
returns the raw content of the tag without the opening and closing tags. so if you have a tag that was parsed from
[i]italic and [bold]test[/b][/i]
you get back
italic and [bold]test[/b]
(yes the tags are messy in that example, that's literally the point, we're showing you the inside bits only ๐)
walk
utility to do a breadth first search ('bfs') over the parsed tree ๐ณ
$tag->walk('bfs', sub {
# tag is in $_
...
return 0;
});
when the sub returns 1 it stops walking the tree. super useful for finding a certain tag โ like a little scavenger hunt but make it code ๐๐
๐ ACCESSORS ๐
the accessors of a tag are currently
name attr attr_raw content finished start end close class
you can call each accessor with get_* and set_* โ so get it, set it, live your truth ๐
nameโ the tag name. for[i]...[/i]it isi, the lowercase tag name.attrโ TODO ๐ (yes that's really what it says, we're not hiding anything from you, bestie)attr_rawโ the raw text of the attribute.contentโ an arrayref of the content of the tag, and each element is either a string or a tag itself. nesting! iconic.finishedโ used during parsing, true if the end of the tag was found. like a little checkbox that goes โ when the closing tag shows up.startโ the original start string, e.g."[size=7]"endโ the original end string, e.g."[/size]"closeโ true if the tag needs a closing tag. a tag which doesn't need a closing tag is[*]for example, inside of[list]tags.classโ'block','inline'or'url'singleโ if this tag does not have a closing tag and also no content, like[hr], for example, set this to true. default is0.numโ absolute number of tag with this name in the tree. useful if you want to number code tags and offer download links. ๐งฎlevelโ level of tag.
for the tag [u] in the following bbcode
[b]bold [i]italic [u]underlined[/u][/i][/b]
it returns 3. deep in the stack, three levels down, main character energy ๐ซถ
quick vibe check: everything above is exactly what the module does โ no invented features, no extra tips, just the facts wearing a cuter outfit โจ
and that's a wrap, bestie!! this page came from the User Contributed Perl Documentation for perl v5.34.0, dated 2022-06-16 โ shoutout to that version and that date for making all of this possible ๐๐ฆ๐ mwah, go parse something gorgeous ๐
๐ฆ where this page comes from
- debian bookworm: libparse-bbcode-perl 0.15-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libparse-bbcode-perl 0.15-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libparse-bbcode-perl 0.15-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libparse-bbcode-perl 0.15-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libparse-bbcode-perl 0.15-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms