protected final function rules(&$text, $rules = null) {
        if($rules === null) {
            $rules = array('except' => array());
        }
        else if(is_array($rules) && count($rules) > 1) {
            $rules = array('only' => $rules);
        }

        if(isset($rules['only']) && is_array($rules['only'])) {
            $rules = $rules['only'];
            foreach($rules as $r) {
                if(!empty($this->tagrules[$r])) {
                    $this->process_tag_rule($r, $this->tagrules[$r], $text);
                }
            }
        }
        else if(isset($rules['except']) && is_array($rules['except'])) {
            $rules = $rules['except'];
            foreach($this->tagrules as $r => $tr) {
                if(!in_array($r, $rules)) {
                    $this->process_tag_rule($r, $tr, $text);
                }
            }
        }
    }