| 1 |
<!doctype html> |
| 2 |
|
| 3 |
<title>CodeMirror: Lua mode</title> |
| 4 |
<meta charset="utf-8"/> |
| 5 |
<link rel=stylesheet href="../../doc/docs.css"> |
| 6 |
|
| 7 |
<link rel="stylesheet" href="../../lib/codemirror.css"> |
| 8 |
<link rel="stylesheet" href="../../theme/neat.css"> |
| 9 |
<script src="../../addon/edit/matchbrackets.js"></script> |
| 10 |
<script src="../../lib/codemirror.js"></script> |
| 11 |
<script src="lua.js"></script> |
| 12 |
<style>.CodeMirror {border: 1px solid black;}</style> |
| 13 |
<div id=nav> |
| 14 |
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
| 15 |
|
| 16 |
<ul> |
| 17 |
<li><a href="../../index.html">Home</a> |
| 18 |
<li><a href="../../doc/manual.html">Manual</a> |
| 19 |
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
| 20 |
</ul> |
| 21 |
<ul> |
| 22 |
<li><a href="../index.html">Language modes</a> |
| 23 |
<li><a class=active href="#">Lua</a> |
| 24 |
</ul> |
| 25 |
</div> |
| 26 |
|
| 27 |
<article> |
| 28 |
<h2>Lua mode</h2> |
| 29 |
<form><textarea id="code" name="code"> |
| 30 |
--[[ |
| 31 |
example useless code to show lua syntax highlighting |
| 32 |
this is multiline comment |
| 33 |
]] |
| 34 |
|
| 35 |
function blahblahblah(x) |
| 36 |
|
| 37 |
local table = { |
| 38 |
"asd" = 123, |
| 39 |
"x" = 0.34, |
| 40 |
} |
| 41 |
if x ~= 3 then |
| 42 |
print( x ) |
| 43 |
elseif x == "string" |
| 44 |
my_custom_function( 0x34 ) |
| 45 |
else |
| 46 |
unknown_function( "some string" ) |
| 47 |
end |
| 48 |
|
| 49 |
--single line comment |
| 50 |
|
| 51 |
end |
| 52 |
|
| 53 |
function blablabla3() |
| 54 |
|
| 55 |
for k,v in ipairs( table ) do |
| 56 |
--abcde.. |
| 57 |
y=[=[ |
| 58 |
x=[[ |
| 59 |
x is a multi line string |
| 60 |
]] |
| 61 |
but its definition is iside a highest level string! |
| 62 |
]=] |
| 63 |
print(" \"\" ") |
| 64 |
|
| 65 |
s = math.sin( x ) |
| 66 |
end |
| 67 |
|
| 68 |
end |
| 69 |
</textarea></form> |
| 70 |
<script> |
| 71 |
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
| 72 |
matchBrackets: true, |
| 73 |
theme: "neat" |
| 74 |
}); |
| 75 |
</script> |
| 76 |
|
| 77 |
<p>Loosely based on Franciszek |
| 78 |
Wawrzak's <a href="https://codemirror.net/1/contrib/lua">CodeMirror |
| 79 |
1 mode</a>. One configuration parameter is |
| 80 |
supported, <code>specials</code>, to which you can provide an |
| 81 |
array of strings to have those identifiers highlighted with |
| 82 |
the <code>lua-special</code> style.</p> |
| 83 |
<p><strong>MIME types defined:</strong> <code>text/x-lua</code>.</p> |
| 84 |
|
| 85 |
</article> |