-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
169 lines (141 loc) · 3.58 KB
/
index.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHPHighlight example</title>
<link type="text/css" rel="stylesheet" href="css/highlighter.css">
</head>
<body>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$text = '
<h2>PHP</h2>
<pre data-file="php-highlight/examples/index.php" data-lang="php">
<?php
abstract class AbstractClass
{
/**
* Our abstract method only needs to define the required arguments
*/
abstract protected function prefixName(string $name): string;
}
class ConcreteClass extends AbstractClass
{
/**
* Our child class may define optional arguments not in the parent\'s signature
*/
public function prefixName(string $name): string
{
$prefix = "";
if ($name === "Pacman") {
$prefix = "Mr.";
} elseif ($name === "Pacwoman") {
$prefix = "Mrs.";
} else {
}
return $prefix . " " . $name;
}
}
$class = new ConcreteClass;
echo $class->prefixName("Pacman"), "\n";
echo $class->prefixName("Pacwoman"), "\n";
</pre>
<h2>JavaScript</h2>
<pre data-file="example.js" data-lang="js">
// Arrow functions let us omit the `function` keyword. Here `long_example`
// points to an anonymous function value.
const long_example = (input1, input2) => {
console.log("Hello, World!");
const output = input1 + input2;
return output;
};
const short_example = input => input + 5;
long_example(2, 3); // Prints "Hello, World!" and returns 5.
short_example(2); // Returns 7.
</pre>
<h2>Bash</h2>
<pre data-file="example.sh" data-lang="bash">
#!/bin/bash
read -p "Enter number : " n
if test $n -ge 0
then
echo "$n is positive number."
else
echo "$n number is negative number."
fi
</pre>
<h2>Go</h2>
<pre data-lang="go" data-file="main.go">
package main
import "fmt"
func f(from string) {
for i := 0; i < 3; i++ {
fmt.Println(from, ":", i)
}
}
func main() {
f("direct")
go f("goroutine")
go func(msg string) {
fmt.Println(msg)
}("going")
fmt.Scanln()
fmt.Println("done")
}
</pre>
<h2>Xml</h2>
<pre data-lang="xml" data-file="recipe.xml">
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE recipe>
<recipe name="bread" preptime="5min" cooktime="180min">
<title>
Simple bread
</title>
<composition>
<ingredient amount="3" unit="glass">Flour</ingredient>
<ingredient amount="0.25" unit="gram">Yeast</ingredient>
<ingredient amount="1.5" unit="glass">Warm water</ingredient>
</composition>
<instructions>
<step>
Mix all ingredients and knead thoroughly.
</step>
<step>
Cover with a cloth and leave for one hour in a warm room.
</step>
<step>
Knead again, put on a baking sheet and put in the oven.
</step>
</instructions>
</recipe>
</pre>
<h2>HTML</h2>
<pre data-lang="html" data-file="index.html">
<!DOCTYPE html>
<title>Title</title>
<style>body {width: 500px;}</style>
<script type="application/javascript">
function $init() {return true;}
</script>
<body>
<p class="title" id=\'title\'>Title</p>
<!-- here goes the rest of the page -->
<div class="actions">
Mix all ingredients and knead thoroughly.
</div>
</body>
</pre>
';
require_once '../vendor/autoload.php';
use Demyanovs\PHPHighlight\Highlighter;
use Demyanovs\PHPHighlight\Themes\ObsidianTheme;
$highlighter = new Highlighter($text, ObsidianTheme::TITLE);
// Configuration
$highlighter->showLineNumbers(true);
$highlighter->showActionPanel(true);
echo $highlighter->parse();
?>
</body>
</html>