Merge remote-tracking branch 'upstream/2018.08-rc' into ap1

This commit is contained in:
Michael 2018-09-22 15:18:53 +00:00
commit c083ae047c
69 changed files with 16128 additions and 16187 deletions

View file

@ -1454,7 +1454,7 @@ function get_responses(array $conv_responses, array $response_verbs, $ob, array
$ret = [];
foreach ($response_verbs as $v) {
$ret[$v] = [];
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], '');
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], 0);
$ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', []);
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');
if (count($ret[$v]['list']) > MAX_LIKERS) {

View file

@ -1911,58 +1911,3 @@ function format_network_name($network, $url = 0) {
return $network_name;
}
}
/**
* @brief Syntax based code highlighting for popular languages.
* @param string $s Code block
* @param string $lang Programming language
* @return string Formated html
*/
function text_highlight($s, $lang) {
if ($lang === 'js') {
$lang = 'javascript';
}
if ($lang === 'bash') {
$lang = 'sh';
}
// @TODO: Replace Text_Highlighter_Renderer_Html by scrivo/highlight.php
// Autoload the library to make constants available
class_exists('Text_Highlighter_Renderer_Html');
$options = [
'numbers' => HL_NUMBERS_LI,
'tabsize' => 4,
];
$tag_added = false;
$s = trim(html_entity_decode($s, ENT_COMPAT));
$s = str_replace(' ', "\t", $s);
/*
* The highlighter library insists on an opening php tag for php code blocks. If
* it isn't present, nothing is highlighted. So we're going to see if it's present.
* If not, we'll add it, and then quietly remove it after we get the processed output back.
*/
if ($lang === 'php' && strpos($s, '<?php') !== 0) {
$s = '<?php' . "\n" . $s;
$tag_added = true;
}
$renderer = new Text_Highlighter_Renderer_Html($options);
$factory = new Text_Highlighter();
$hl = $factory->factory($lang);
$hl->setRenderer($renderer);
$o = $hl->highlight($s);
$o = str_replace("\n", '', $o);
if ($tag_added) {
$b = substr($o, 0, strpos($o, '<li>'));
$e = substr($o, strpos($o, '</li>'));
$o = $b . $e;
}
return '<code>' . $o . '</code>';
}