本文整理汇总了PHP中GeSHi::set_xhtml_compliance方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::set_xhtml_compliance方法的具体用法?PHP GeSHi::set_xhtml_compliance怎么用?PHP GeSHi::set_xhtml_compliance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::set_xhtml_compliance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* The main method of the Plugin
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
* @return The content that is displayed on the website
*/
function main($content, $config)
{
// get content
$this->pi_initPIflexForm();
$config['content.']['lang'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'cLang', 'sVIEW');
$config['content.']['code'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'cCode', 'sVIEW');
$config['content.']['highlight'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'cHighlight', 'sOPTIONS');
$config['content.']['startnumber'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'cStartnumber', 'sOPTIONS');
// init geshi library
$this->geshi = new GeSHi($config['content.']['code'], $config['content.']['lang']);
// defaults
$this->geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
// set highlighted lines
if ($config['content.']['highlight'] !== '') {
$this->geshi->highlight_lines_extra(split(',', $config['content.']['highlight']));
}
// set startnumber
if (isset($config['content.']['startnumber'])) {
$this->geshi->start_line_numbers_at($config['content.']['startnumber']);
}
// style
if (isset($config['default.'])) {
$this->_styleSubjects($config['default.']);
}
if (isset($config[$config['content.']['lang'] . '.'])) {
$this->_styleSubjects($config[$config['content.']['lang'] . '.']);
}
// external stylesheets
if (isset($config['global.']['external']) && $config['global.']['external'] == 0) {
// do not use external style sheets
} else {
// mtness.net modification: I love stylesheets!
$this->geshi->enable_classes();
// Echo out the stylesheet for this code block And continue echoing the page
$this->geshiCSS = '<style type="text/css"><!--' . $this->geshi->get_stylesheet() . '--></style>';
// additional headerdata to include the styles
$GLOBALS['TSFE']->additionalHeaderData['dev_null_geshi:' . $config['content.']['lang']] = $this->geshiCSS;
}
// xhtml compliance
if (isset($config['global.']['xhtmlcompliant']) && $config['global.']['xhtmlcompliant'] == 1) {
$this->geshi->set_xhtml_compliance(true);
}
// check for errors
if ($this->geshi->error() !== false) {
// log an error, this happens if the language file is missing or non-readable. Other input
// specific errors can also occour, eg. if a non-existing container type is set for the engine.
$GLOBALS['BE_USER']->simplelog($this->geshi->error(), $extKey = 'dev_null_geshi', 1);
}
// render
return $this->pi_wrapInBaseClass($this->geshi->parse_code());
}