Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/parser/PhutilPygmentizeParser.php
Show All 26 Lines | public function parse($block) { | ||||
$len = strlen($block); | $len = strlen($block); | ||||
$out = ''; | $out = ''; | ||||
$mode = 'text'; | $mode = 'text'; | ||||
for ($ii = 0; $ii < $len; $ii++) { | for ($ii = 0; $ii < $len; $ii++) { | ||||
$c = $block[$ii]; | $c = $block[$ii]; | ||||
switch ($mode) { | switch ($mode) { | ||||
case 'text': | case 'text': | ||||
// We're in general text between tags, and just passing characers | // We're in general text between tags, and just passing characters | ||||
// through unmodified. | // through unmodified. | ||||
if ($c == '<') { | if ($c == '<') { | ||||
$mode = 'tag'; | $mode = 'tag'; | ||||
} | } | ||||
$out .= $c; | $out .= $c; | ||||
break; | break; | ||||
case 'tag': | case 'tag': | ||||
// We're inside a tag, and looking for `class="` so we can rewrite | // We're inside a tag, and looking for `class="` so we can rewrite | ||||
Show All 40 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0