code snippet
Ik ben op zoek naar een plugin dat je een stuk html of php code kan tonen op je site.
Zeg maar zoiets
Ik heb al gegoogled op code snippet/ code wrap, maar eigenlijk komt dit niet eens in de buurt. Hoe heet zo'n dergelijke plugin?
<code>
</code>
ik denk dat dennis een cms gebruikt zoals wordpress.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<style type="text/css">
.block{
width: 750px;
height: auto;
background-color: #F0F0EF;
}
.code{
width: 700px;
height: auto;
min-height: 100px;
}
.linenum{
text-align:right;
background:#FDECE1;
border:1px solid #cc6666;
padding:0px 1px 0px 1px;
font-family:Courier New, Courier;
float:left;
width:auto;
margin:3px 0px 30px 0px;
}
code {/* safari/konq hack */
font-family:Courier New, Courier;
}
.linetext{
overflow: auto;
white-space: nowrap;
overflow-y: hidden;
-ms-overflow-y: hidden;
width:700px;
text-align:left;
background:white;
border:1px solid #cc6666;
border-left:0px;
padding:0px 1px 0px 8px;
font-family:Courier New, Courier;
float:left;
margin:3px 0px 30px 0px;
}
.clear{
clear:both;
}
</style>
<form action="" method="POST">
<textarea class="code" name="code">
<?php
//your code here
?>
</textarea>
<br/><input type="submit" value="Show my code!"/>
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if($_POST['code']){
$count = explode("\n",$_POST['code']);
$count = count($count);
echo '
<div class="block">
<div class="linenum">
';
for($i=1;$i<=$count;$i++){
echo $i.'<br/>';
}
echo '
</div>
<div class="linetext">
';
code();
echo $_POST['code'];
code();
echo '
</div>
</div>
<div class="clear"></div>
';
}
}
function code() {
static $on = false;
if ( !$on ) {
ob_start();
}
else {
$buffer = ob_get_contents();
ob_end_clean();
$highlight = highlight_string( $buffer );
}
$on = !$on;
}
?>
.block{
width: 750px;
height: auto;
background-color: #F0F0EF;
}
.code{
width: 700px;
height: auto;
min-height: 100px;
}
.linenum{
text-align:right;
background:#FDECE1;
border:1px solid #cc6666;
padding:0px 1px 0px 1px;
font-family:Courier New, Courier;
float:left;
width:auto;
margin:3px 0px 30px 0px;
}
code {/* safari/konq hack */
font-family:Courier New, Courier;
}
.linetext{
overflow: auto;
white-space: nowrap;
overflow-y: hidden;
-ms-overflow-y: hidden;
width:700px;
text-align:left;
background:white;
border:1px solid #cc6666;
border-left:0px;
padding:0px 1px 0px 8px;
font-family:Courier New, Courier;
float:left;
margin:3px 0px 30px 0px;
}
.clear{
clear:both;
}
</style>
<form action="" method="POST">
<textarea class="code" name="code">
<?php
//your code here
?>
</textarea>
<br/><input type="submit" value="Show my code!"/>
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if($_POST['code']){
$count = explode("\n",$_POST['code']);
$count = count($count);
echo '
<div class="block">
<div class="linenum">
';
for($i=1;$i<=$count;$i++){
echo $i.'<br/>';
}
echo '
</div>
<div class="linetext">
';
code();
echo $_POST['code'];
code();
echo '
</div>
</div>
<div class="clear"></div>
';
}
}
function code() {
static $on = false;
if ( !$on ) {
ob_start();
}
else {
$buffer = ob_get_contents();
ob_end_clean();
$highlight = highlight_string( $buffer );
}
$on = !$on;
}
?>
Gewijzigd op 20/03/2012 11:20:43 door gerhard l