Added inline code chunk editing possibility.

Signed-off-by: Gergely Polonkai (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely Polonkai (W00d5t0ck) 2012-09-14 19:09:50 +02:00
parent 351102255c
commit 3f5d817f38

View File

@ -86,6 +86,23 @@ class CodeChunk extends \Twig_Extension
$string = substr_replace($string, $replacement, $start, $len); $string = substr_replace($string, $replacement, $start, $len);
} }
while (
preg_match(
'/\\[\\$ code:([^:]+):(.+?) \\$\\]/is',
$string, $m, PREG_OFFSET_CAPTURE)
) {
$start = $m[0][1];
$fullTag = $m[0][0];
$len = strlen($fullTag);
$lang = strtolower($m[1][0]);
$code = $m[2][0];
$replacement = '<div class="code-chunk">' . $this->hiliter->geshiFilter($code, $lang) . '</div>';
$string = substr_replace($string, $replacement, $start, $len);
}
return $string; return $string;
} }