Example #1
0
 /**
  * Performs the required changes after Parsedown has interpreted the input
  *
  * @param   string          $original   Contains the original text, before
  *                                      preMarkdownHook and Parsedown have done their jobs.
  * @param   MarkdownData    $data       Contains the text parsed so far
  * @return  void                        The parsed text is returned in $data
  *
  * @author Frank Wikström <*****@*****.**>
  **/
 public static function postMarkdownHook($original, $data)
 {
     $text = trim($data->text);
     $rules = Rule::remember(5, 'cached_rules')->get();
     // First put back all the protected items
     foreach (self::$dictionary as $key => $value) {
         $text = str_replace($key, $value, $text);
     }
     // Then process the other replacement rules.
     foreach ($rules as $rule) {
         if (!$rule->is_protected) {
             $avoid = $rule->start_markdown . $rule->close_markdown;
             $delimiter = self::getDelimiter($avoid);
             $search = $delimiter . preg_quote($rule->start_markdown) . '(.*?)' . preg_quote($rule->close_markdown) . $delimiter . 's';
             $replace = $rule->start_tag . '$1' . $rule->close_tag;
             $text = preg_replace($search, $replace, $text);
         }
     }
     $data->text = $text;
 }