Modules/Doc: Add Syntax highlighting for PHP code

refs #4820
This commit is contained in:
Eric Lippmann 2014-02-11 17:04:58 +01:00
parent 7f099b211b
commit 5a913881a6
2 changed files with 31 additions and 12 deletions

View File

@ -8,6 +8,7 @@ INI files as source it enables you to store configuration in a familiar format.
defines some configuration files for its own purposes. Please note that both modules and framework
keep their main configuration in the INI file called config.ini. Here's some example code:
```php
<?php
use \Icinga\Application\Config as IcingaConfig;
@ -23,6 +24,7 @@ keep their main configuration in the INI file called config.ini. Here's some exa
// the module's config.ini. For using other files you have to pass this parameter though.
// The following example loads values from the example module's extra.ini:
IcingaConfig::module('example', 'extra')->logging->get('enabled', true);
```
## Reload from disk

View File

@ -126,9 +126,26 @@ class DocParser
$fileObject->flock(LOCK_UN);
}
$html = Parsedown::instance()->parse(implode('', $cat));
$html = preg_replace_callback(
'#<pre><code class="language-php">(.*?)\</code></pre>#s',
array($this, 'highlight'),
$html
);
return array($html, $toc[0]->item);
}
/**
* Syntax highlighting for PHP code
*
* @param $match
*
* @return string
*/
protected function highlight($match)
{
return highlight_string(htmlspecialchars_decode($match[1]), true);
}
/**
* Extract atx- or setext-style headers from the given lines
*