You are here

protected function Markdown::encodeAmpsAndAngles in Markdown 7

* Smart processing for ampersands and angle brackets that need to * be encoded. Valid character entities are left alone unless the * no-entities mode is set. *

Parameters

string $text: * @return string

1 call to Markdown::encodeAmpsAndAngles()
Markdown::encodeAttribute in includes/Markdown.php
* Encode text for a double-quoted HTML attribute. This function * is *not* suitable for attributes enclosed in single quotes. *

File

includes/Markdown.php, line 1593

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected function encodeAmpsAndAngles($text) {
  if ($this->no_entities) {
    $text = str_replace('&', '&', $text);
  }
  else {

    // Ampersand-encoding based entirely on Nat Irons's Amputator
    // MT plugin: <http://bumppo.net/projects/amputator/>
    $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\\w+);)/', '&amp;', $text);
  }

  // Encode remaining <'s
  $text = str_replace('<', '&lt;', $text);
  return $text;
}