site-tpe/EnlighterJS/Development.phtml
2025-05-16 18:49:08 +02:00

244 lines
No EOL
6.3 KiB
PHTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Favicon !-->
<link rel="icon" href="Resources/favicon.png" type="image/png" />
<title>EnlighterJS Playground</title>
<!-- Bootstrap CSS - just 4 styling ;) -->
<link rel="stylesheet" href="Resources/bootstrap/bootstrap.min.css" />
<link href='https://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<!-- EnlighterJS Styles -->
<?php
require('Util/global.php');
$theme = 'eclipse';
foreach ($sources->css as $css){
echo '<link rel="stylesheet" href="', $css, '" />', "\n";
}
?>
<link rel="stylesheet" href="Source/Themes/Minimal.css?<?php echo time() ?>" />
<!-- Include MooTools Framework -->
<script type="text/javascript" src="Resources/MooTools.min.js"></script>
<script type="text/javascript">
// attention: don't use load or domready here! the jsloaded event is triggered by DynamicSourcefileLoader
window.addEvent('domready', function(){
var options = {
language : 'js',
theme: 'minimal',
rawButton: true,
windowButton: true,
indent : 2,
infoButton: true,
showLinenumbers: true
};
//document.getElements('pre.special').enlight(options);
//document.id('NoLight').enlight(true).enlight(false);
EnlighterJS.Util.Init('pre', 'code', options);
/*
EnlighterJS.Util.Helper(document.getElements('pre.special'), Object.merge(options,{
renderer : 'Block',
}));
EnlighterJS.Util.Helper(document.getElements('code.special'), Object.merge(options,{
renderer : 'Inline',
}));
*/
});
</script>
<script type="text/css">
</script>
</head>
<body>
<!-- Begin page content -->
<div class="container">
<h1>
<strong>EnlighterJS</strong> <small>Development Playground</small>
</h1>
<div id="content">
<!-- ############################################################# -->
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
<code data-enlighter-language="lua">local a = "Double Quoted\nString"</code> invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.
</p>
<pre data-enlighter-language="lua">
-- SOURCE: http://www.lua.org/manual/5.3/manual.html
-- COMMENTS
-- --------------------------------------------------
-- This is a single line comment
print "Hello World!"
--[[Comments can be spread
across several lines ]]
print "Hello World!"
---[[The long handled doubleshovel means that this code will run
print "This will print because it is not a comment!"
-- We can still include comments by prefixing them with a doubledash
-- print "This will not print because it is commented out"
]]
-- STRINGS
-- --------------------------------------------------
local a = "Double Quoted\nString"
local b = 'Double Quoted\nString'
local c = [[Multi
Line String
]]
a = 'alo\n123"'
a = "alo\n123\""
a = '\97lo\10\04923"'
a = [[alo
123"]]
a = [==[
alo
123"]==]
-- NUMBERS
-- --------------------------------------------------
a = 4
b = 0.4
c = 4.57e-3
D = 0.3e12
e = 5e+20
-- TABLES
-- --------------------------------------------------
a = {} -- create a table and store its reference in `a'
k = "x"
a[k] = 10 -- new entry, with key="x" and value=10
a[20] = "great" -- new entry, with key=20 and value="great"
print(a["x"]) --> 10
k = 20
print(a[k]) --> "great"
a["x"] = a["x"] + 1 -- increments entry "x"
print(a["x"]) --> 11
days = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"}
-- EXAMPLE
-- --------------------------------------------------
line = io.read() -- read a line
n = tonumber(line) -- try to convert it to a number
if n == nil then
error(line .. " is not a valid number")
else
print(n*2)
end
function foo (a)
print("foo", a)
return coroutine.yield(2*a)
end
co = coroutine.create(function (a,b)
print("co-body", a, b)
local r = foo(a+1)
print("co-body", r)
local r, s = coroutine.yield(a+b, a-b)
print("co-body", r, s)
return b, "end"
end)
print("main", coroutine.resume(co, 1, 10))
print("main", coroutine.resume(co, "r"))
print("main", coroutine.resume(co, "x", "y"))
print("main", coroutine.resume(co, "x", "y"))
list = nil
for line in io.lines() do
list = {next=list, value=line}
end
x = 10
local i = 1 -- local to the chunk
while i<=x do
local x = i*2 -- local to the while body
print(x) --> 2, 4, 6, 8, ...
i = i + 1
end
if i > 20 then
local x -- local to the "then" body
x = 20
print(x + 2)
else
print(x) --> 10 (the global one)
end
print(x) --> 10 (the global one)
do
local a2 = 2*a
local d = sqrt(b^2 - 4*a*c)
x1 = (-b + d)/a2
x2 = (-b - d)/a2
end -- scope of `a2' and `d' ends here
print(x1, x2)
</pre>
<!-- ############################################################# -->
</div>
<!-- // content -->
</div>
<!-- // container -->
<!-- Sticky Footer Message -->
<div id="footer">
<div class="container">
<p class="">
<strong>EnlighterJS</strong> is developed by <a href="http://andidittrich.de">Andi Dittrich</a><br /> <a href="https://github.com/AndiDittrich/EnlighterJS/archive/master.zip">Download</a> EnlighterJS on <a href="https://github.com/AndiDittrich/EnlighterJS">GitHub</a> | It's released under the Terms of <a href="../LICENSE.md">MIT X11 License</a> | Demo created with <a href="http://getbootstrap.com">Bootstrap</a>
</p>
</div>
</div>
<!-- // Sticky Footer Message -->
<!-- EnlighterJS Sourcefiles -->
<script type="text/javascript">/* <![CDATA[ */
(function(){
'use strict';
<?php
foreach ($sources->js as $js){
$x = file_get_contents($js);
echo preg_replace('#^/\*[\s\S]+\*/#Ui', '', $x);
}
?>
})();
/* ]]> */</script>
</body>
</html>