1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

RegEx to Completely Remove BBCode in Text.php

Discussion in 'XenForo Development Discussions' started by Snog, Aug 4, 2015.

  1. Snog

    Snog Well-Known Member

    I have an application where I have a custom BBCode to insert some meta data into a post. For the thread preview and/or the meta page description I need to completely remove that tag.

    The tag itself is something like this..
    Code:
    <meta itemprop="property" content="MIXEDVALUE">
    In BbCode/Formatter/Text.php I have this code..
    Code:
    tags['tagname'] = array(
       'hasOption' => true,
       'optionRegex' => '/([A-Z])\w+/',
       'replace' => array('<meta itemprop="property" content="\'%s\'', '"\/>')
    );
    
    That code does strip everything except the MIXEDVALUE.

    Which I don't exactly understand because the 'optionRegex' does match the MIXEDVALUE perfectly.

    What am I missing here?

    EDIT: The other part in Text.php is this...
    Code:
    public function handleTagTagname(array $tag, array $rendererStates)
    {
           $output = $this->renderSubTree($tag['children'], $rendererStates);
           return "";
    }
    
     
    Last edited: Aug 4, 2015
  2. Snog

    Snog Well-Known Member

    The text.php does not work quite the way I thought it did. I found that the snippet template helper is a better way to go.
     

Share This Page