Skip to content

Commit fe728b0

Browse files
committed
Web: Use GeSHi for syntax highlighting from the "online demo report" code
1 parent d863df4 commit fe728b0

5 files changed

Lines changed: 5289 additions & 1 deletion

File tree

demo/report/index.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ function cut_string($string, $length = 1024) {
6666
}
6767

6868
if ($isCodePosted) { //if code posted...
69+
include_once '../../site/geshi/geshi.php';
70+
71+
$geshi = new GeSHi($_POST['code'], 'cpp');
72+
$geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
73+
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
74+
$geshi->set_overall_class('geshicode');
75+
6976
echo "<h3>Input</h3>\n";
70-
echo "<pre class=\"code\">" . htmlspecialchars($_POST['code']) . "</pre>\n";
77+
echo $geshi->parse_code();
7178

7279
echo "<h3>Output</h3>\n";
7380

site/css/all.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ pre.code {
126126
pre.code em {
127127
color: green;
128128
}
129+
.geshicode {
130+
padding: .5em;
131+
background: #f7f7f7;
132+
border: 1px solid #e2e2e2;
133+
}
129134

130135
/* Printing */
131136
@media print {

0 commit comments

Comments
 (0)