Added escape sequences that allow "literal" inline tags in descriptions.

This commit is contained in:
Vasil Rangelov
2012-11-10 11:49:23 +02:00
parent e0a5a75364
commit 044ebd68c9
2 changed files with 93 additions and 11 deletions
@@ -71,11 +71,14 @@ class LongDescription implements \Reflector
# Match nested inline tags.
# Because we did not catch the tag delimiters
# earlier, we must be explicit with them here.
# Notice that this also matches "{}", as a way to
# later introduce it as an escape sequence.
\{(?1)?\}
|
# "{@}" is not a valid inline tag. This ensures that
# having it occur inside an inline tag does not trip
# us up.
# us up. While this is required in any event, notice
# that this is also later an escape sequence.
\{\@\}
|
# If we are not dealing with a nested inline tag,
@@ -98,6 +101,17 @@ class LongDescription implements \Reflector
$this->parsedContents[$i]
);
}
//In order to allow "literal" inline tags, the otherwise invalid
//sequence "{@}" is changed to "@", and "{}" is changed to "}".
//See unit tests for examples.
for ($i=0, $l = count($this->parsedContents); $i<$l; $i += 2) {
$this->parsedContents[$i] = str_replace(
array('{@}', '{}'),
array('@', '}'),
$this->parsedContents[$i]
);
}
}
return $this->parsedContents;
}