function ext_from_lang($language) { $lang = HyperLanguage::compileFromName($language); return "{$language}:" . implode(',', $lang->extensions()); }
public function __construct($lang) { if (is_string($lang)) { $this->_lang = HyperLanguage::compileFromName(strtolower($lang)); } else { if ($lang instanceof HyperlightCompiledLanguage) { $this->_lang = $lang; } else { if ($lang instanceof HyperLanguage) { $this->_lang = HyperLanguage::compile($lang); } else { trigger_error('Invalid argument type for $lang to Hyperlight::__construct', E_USER_ERROR); } } } foreach ($this->_lang->postProcessors() as $ppkey => $ppvalue) { $this->_postProcessors[$ppkey] = new Hyperlight($ppvalue); } $this->reset(); }
public function render($code) { if (false === $this->language()) { $this->_lang = HyperLanguage::compileFromName('code'); $this->reset(); if (!$this->language()) { return htmlspecialchars($code); } } // Normalize line breaks. $this->_code = preg_replace('/\\r\\n?/', "\n", $code); $fm = hyperlight_calculate_fold_marks($this->_code, $this->language()->id()); return hyperlight_apply_fold_marks($this->renderCode(), $fm); }