Skip to content
Joshua Dickerson edited this page Jan 5, 2016 · 1 revision

In version 1.1 the BBC parser was rewritten. It now uses several classes which allow more control of text is parsed. Those classes are wrapped in ParserWrapper to make it just as easy to use as before.

Codes

The Bulletin Board Codes are in their own class which allows you to change them out and create new parsers for each string type.

New attributes

In the old format you would use text strings for the options and parameters of the BBC. In the new version, you should use the constants of the Codes class. Attributes, the top level of your code, are prefixed with ATTR_. If you are converting an old BBC to the new format, just uppercase the old attribute and add "Codes::ATTR_" and it will work. For instance Codes::ATTR_TEST or Codes::ATTR_DISABLED_BEFORE.

  • ATTR_LENGTH the length of the tag. Not optional and must be correct or your tag won't parse.
  • ATTR_AUTOLINK denotes whether the contents can be autolinked. Replaces the old $autolink_areas. Boolean value.
  • ATTR_BLOCKLEVEL whether the code is block level. Not optional!
  • ATTR_NO_CACHE if this is true, the message will be considered not cacheable. This would happen if your parsed code uses something like $user_info['id'] where it will be different for each user.

Hooks

  • item_codes change the item_codes array
  • bbc_codes_parsing this is where you should add your new BBC. More on that later
  • bbc_set_printing if the page is going to be printed, it calls this method before parsing. If your BBC should change anything for printing, use this hook

Autolinker

The autolinker takes web addresses like www.elkarte.com and http://elkarte.com and email addresses like info@elkarte.com and makes them links. Surrounding BBC can enable/disable the parsing of these links so it receives strings from the parser.

Hooks

  • autolink_area allows you to change the autolinked area
  • autolink_load change the autolink regular expressions (and add more)
  • possible_autolink if you add more autolinkers, you will want to also check to see if you can parse them