function geshifilter_filter_tips in GeSHi Filter for syntax highlighting 5
Same name and namespace in other branches
- 5.2 geshifilter.module \geshifilter_filter_tips()
- 6 geshifilter.module \geshifilter_filter_tips()
- 7 geshifilter.module \geshifilter_filter_tips()
Implementation of hook_filter_tips()
File
- ./
geshifilter.module, line 42
Code
function geshifilter_filter_tips($delta, $format, $long = false) {
$default_type = variable_get('geshifilter_default_type_' . $format, 0);
$types = variable_get('geshifilter_types_' . $format, array());
$start_param = variable_get('geshifilter_start_attribute', FALSE);
$line_numbers = variable_get('geshifilter_line_numbers', GESHI_NO_LINE_NUMBERS);
$inline_code = variable_get('geshifilter_inline_code_' . $format, FALSE);
if ($long) {
$text = t('<h3>Code:</h3>');
//some language are allowed, type param is supported
if (!$types[0]) {
$text .= t('<p>To post highlighted code, surround it code with <blockcode [type="<em>language</em>"]>...</blockcode> tags.</p><p>E.g. actionscript block code:<pre><blockcode type="<em>actionscript</em>"><br />...<br /></blockcode></pre></p>');
if ($inline_code) {
$text .= t('<p>You may also post highlighted inline code surrounding it with <code [type="<em>language</em>"]>...</code> tags.</p><p>E.g. highlight actionscript inline code:<pre><code type="<em>actionscript</em>">...</code></pre></p>');
}
if ($default_type) {
$text .= t('<p>If you don\'t use <em>type="language"</em> param or specify an unsupported language, the code will be highlighted as %default-code code.</p>', array(
'%default-code' => theme('placeholder', $default_type),
));
}
else {
$text .= t('<p>If you don\'t use <em>type="language"</em> param or specify an unsupported language, the code will not be highlighted.</p>');
}
$supported_types = array_keys($types, TRUE);
$text .= t('<p>The following languages are supported for highlight:<br />%type_list.</p>', array(
'%type_list' => theme('item_list', $supported_types),
));
}
else {
$text .= t('<p>To post code, surround it with <blockcode>...</blockcode> tags.</p><p>E.g. <pre><blockcode><br />...<br /></blockcode></pre></p>');
if ($inline_code) {
$text .= t('<p>You may also post inline code surrounding it with <code>...</code> tags.</p><p>E.g.: <pre><code>...</code></pre></p>');
}
if ($default_type) {
$text .= t('<p>By default, the code will be highlighted as %default-code code.</p>', array(
'%default-code' => theme('placeholder', $default_type),
));
}
else {
$text .= t('<p>The code will not be highlighted.</p>');
}
}
if ($line_numbers == GESHI_NORMAL_LINE_NUMBERS || $line_numbers == GESHI_FANCY_LINE_NUMBERS) {
//line numbers
if ($start_param) {
$text .= ' ' . t('<p>The code will be numbered. You can make the line numbers start at any number using <em>start=number</em> param</p><p>E.g. highlight actionscript code and start line number at 5: <pre><blockcode type="<em>actionscript</em>" start="<em>5</em>"><br />...<br /></blockcode></pre></p>');
}
else {
$text .= ' ' . t('<p>The code will be numbered.</p>');
}
}
return $text;
}
else {
$text = '';
//some language are allowed, type param is supported
if (!$types[0]) {
$text .= t('You may post block code using <blockcode [type="<em>language</em>"]>...</blockcode> tags. ');
if ($inline_code) {
$text .= t('You may also post inline code using <code [type="<em>language</em>"]>...</code> tags.');
}
}
else {
$text .= t('You may post block code using <blockcode>...</blockcode> tags. ');
if ($inline_code) {
$text .= t('You may also post inline code using <code>...</code> tags.');
}
}
return $text;
}
}