---
name: "Parse::BBCode::Tag"
section: "3pm"
platform: "linux"
package: "libparse-bbcode-perl"
version: "0.15-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Parse::BBCode::Tag"
---

# Parse::BBCode::Tag(3pm)

Tag Class for Parse::BBCode

## NAME

Parse::BBCode::Tag - Tag Class for Parse::BBCode

## DESCRIPTION

If you parse a bbcode with Parse::BBCode `"Parse::BBCode::parse"` returns a parse tree of Tag objects.

## METHODS

- add\_content

  ```
      $tag->add_content('string');
  ```

  Adds 'string' to the end of the tag content.

  ```
      $tag->add_content($another_tag);
  ```

  Adds `$another_tag` to the end of the tag content.

- raw\_text

  ```
      my $bbcode = $tag->raw_text;
  ```

  Returns the raw text of the parse tree, so all tags are converted back to bbcode.

- raw\_content

  ```
      my $bbcode = $tag->raw_content;
  ```

  Returns the raw content of the tag without the opening and closing tags. So if you have tag that was parsed from

  ```
      [i]italic and [bold]test[/b][/i]
  ```

  it will return

  ```
      italic and [bold]test[/b]
  ```

- 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. Useful for finding a certain tag.

## 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_*"`

- name

  The tag name. for `"[i]...[/i]"` it is `"i"`, the lowercase tag name.

- attr

  TODO

- attr\_raw

  The raw text of the attribute

- content

  An arrayref of the content of the tag, each element either a string or a tag itself.

- finished

  Used during parsing, true if the end of the tag was found.

- 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 is 0.

- 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.
