Path: blob/master/src/infrastructure/markup/syntax/highlighter/PhutilRainbowSyntaxHighlighter.php
12242 views
<?php12/**3* Highlights source code with a rainbow of colors, regardless of the language.4* This highlighter is useless, absurd, and extremely slow.5*/6final class PhutilRainbowSyntaxHighlighter extends Phobject {78private $config = array();910public function setConfig($key, $value) {11$this->config[$key] = $value;12return $this;13}1415public function getHighlightFuture($source) {1617$color = 0;18$colors = array(19'rbw_r',20'rbw_o',21'rbw_y',22'rbw_g',23'rbw_b',24'rbw_i',25'rbw_v',26);2728$result = array();29foreach (phutil_utf8v($source) as $character) {30if ($character == ' ' || $character == "\n") {31$result[] = $character;32continue;33}34$result[] = phutil_tag(35'span',36array('class' => $colors[$color]),37$character);38$color = ($color + 1) % count($colors);39}4041$result = phutil_implode_html('', $result);42return new ImmediateFuture($result);43}4445}464748