diff --git a/index.html b/index.html
index ec3575c..b43e6a1 100644
--- a/index.html
+++ b/index.html
@@ -1,3 +1,5 @@
+$render{"lexer-test"}
+
$render{"templates/wares"}
Posts
diff --git a/lexer-test.html b/lexer-test.html
new file mode 100644
index 0000000..1b61e7e
--- /dev/null
+++ b/lexer-test.html
@@ -0,0 +1,10 @@
+class Thing
+ name: "unknown"
+
+class Person extends Thing
+ say_name: => print "Hel#lo, I am #{@name}!"
+
+with Person!
+ .name = "MoonScript"
+ \say_name!
+
diff --git a/moonscript.css b/moonscript.css
new file mode 100644
index 0000000..7dce960
--- /dev/null
+++ b/moonscript.css
@@ -0,0 +1,35 @@
+.nb {
+ color: #F69385; }
+
+/* strings */
+.s, .s1, .s2, .se {
+ color: #F1BF8E; }
+
+/* proper names, self */
+.nc, .vc, .bp {
+ color: #99CBCA; }
+
+/* true, false, nil */
+.kc {
+ color: #B3EFE5; }
+
+/* function lit, braces, parens */
+.nf, .kt {
+ color: #B0D89C; }
+
+/* operators */
+.o, .si {
+ color: #F277A1; }
+
+.nv {
+ color: #F277A1; }
+
+/* keywords */
+.k, .kd {
+ color: #BB84B4; }
+
+.c1, .c2 {
+ color: #929292; }
+
+.m, .mi, .mf, .mh {
+ color: #9D8FF2; }
diff --git a/moonscript.py b/moonscript.py
new file mode 100644
index 0000000..135128b
--- /dev/null
+++ b/moonscript.py
@@ -0,0 +1,89 @@
+from pygments.lexer import default, combined, include, words
+from pygments.lexers.scripting import LuaLexer
+from pygments.token import *
+
+def all_lua_builtins():
+ from pygments.lexers._lua_builtins import MODULES
+ return [w for values in MODULES.values() for w in values]
+
+class CustomLexer(LuaLexer):
+ """
+ For MoonScript source code.
+ """
+
+ name = 'MoonScript'
+ url = 'http://moonscript.org'
+ aliases = ['moonscript', 'moon']
+ filenames = ['*.moon']
+ mimetypes = ['text/x-moonscript', 'application/x-moonscript']
+ version_added = '1.5'
+
+ tokens = {
+ 'root': [
+ (r'#!(.*?)$', Comment.Preproc),
+ default('base')
+ ],
+ 'base': [
+ ('--.*$', Comment.Single),
+ (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
+ (r'(?i)\d+e[+-]?\d+', Number.Float),
+ (r'(?i)0x[0-9a-f]*', Number.Hex),
+ (r'\d+', Number.Integer),
+ (r'\n', Whitespace),
+ (r'[^\S\n]+', Text),
+ (r'(?s)\[(=*)\[.*?\]\1\]', String),
+ (r'(->|=>)', Name.Function),
+ (r':[a-zA-Z_]\w*', Name.Variable),
+ (r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),
+ (r'[;,]', Punctuation),
+ (r'[\[\]{}()]', Keyword.Type),
+ (r'[a-zA-Z_]\w*:', Name.Variable),
+ (words((
+ 'class', 'extends', 'if', 'then', 'super', 'do', 'with',
+ 'import', 'export', 'while', 'elseif', 'return', 'for', 'in',
+ 'from', 'when', 'using', 'else', 'and', 'or', 'not', 'switch',
+ 'break'), suffix=r'\b'),
+ Keyword),
+ (r'(true|false|nil)\b', Keyword.Constant),
+ (r'(and|or|not)\b', Operator.Word),
+ (r'(self)\b', Name.Builtin.Pseudo),
+ (r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class),
+ (r'[A-Z]\w*', Name.Class), # proper name
+ (words(all_lua_builtins(), suffix=r"\b"), Name.Builtin),
+ (r'[A-Za-z_]\w*', Name),
+ ("'", String.Single, combined('stringescape', 'sqs')),
+ ('"', String.Double, combined('stringescape', 'dqs')),
+ ],
+ 'stringescape': [
+ (r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)
+ ],
+ 'strings': [
+ (r'[^#\\\'"]+', String),
+ # note that all coffee script strings are multi-line.
+ # hashmarks, quotes and backslashes must be parsed one at a time
+ ],
+ 'interpoling_string': [
+ (r'\}', String.Interpol, "#pop"),
+ include('base')
+ ],
+ 'dqs': [
+ (r'"', String, '#pop'),
+ (r'\\.|\'', String), # double-quoted string don't need ' escapes
+ (r'#\{', String.Interpol, "interpoling_string"),
+ (r'#', String),
+ include('strings')
+ ],
+ 'sqs': [
+ (r"'", String, '#pop'),
+ (r'#|\\.|"', String), # single quoted strings don't need " escapses
+ include('strings')
+ ]
+ }
+
+ def get_tokens_unprocessed(self, text):
+ # set . as Operator instead of Punctuation
+ for index, token, value in LuaLexer.get_tokens_unprocessed(self, text):
+ if token == Punctuation and value == ".":
+ token = Operator
+ yield index, token, value
+
diff --git a/pygments.css b/pygments.css
new file mode 100644
index 0000000..e2cc7b8
--- /dev/null
+++ b/pygments.css
@@ -0,0 +1,73 @@
+pre { line-height: 125%; }
+td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+.hll { background-color: #ffffcc }
+.c { color: #3D7B7B; font-style: italic } /* Comment */
+.err { border: 1px solid #FF0000 } /* Error */
+.k { color: #008000; font-weight: bold } /* Keyword */
+.o { color: #666666 } /* Operator */
+.ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
+.cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
+.cp { color: #9C6500 } /* Comment.Preproc */
+.cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
+.c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
+.cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
+.gd { color: #A00000 } /* Generic.Deleted */
+.ge { font-style: italic } /* Generic.Emph */
+.gr { color: #E40000 } /* Generic.Error */
+.gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.gi { color: #008400 } /* Generic.Inserted */
+.go { color: #717171 } /* Generic.Output */
+.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+.gs { font-weight: bold } /* Generic.Strong */
+.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.gt { color: #0044DD } /* Generic.Traceback */
+.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
+.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
+.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
+.kp { color: #008000 } /* Keyword.Pseudo */
+.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
+.kt { color: #B00040 } /* Keyword.Type */
+.m { color: #666666 } /* Literal.Number */
+.s { color: #BA2121 } /* Literal.String */
+.na { color: #687822 } /* Name.Attribute */
+.nb { color: #008000 } /* Name.Builtin */
+.nc { color: #0000FF; font-weight: bold } /* Name.Class */
+.no { color: #880000 } /* Name.Constant */
+.nd { color: #AA22FF } /* Name.Decorator */
+.ni { color: #717171; font-weight: bold } /* Name.Entity */
+.ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
+.nf { color: #0000FF } /* Name.Function */
+.nl { color: #767600 } /* Name.Label */
+.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+.nt { color: #008000; font-weight: bold } /* Name.Tag */
+.nv { color: #19177C } /* Name.Variable */
+.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+.w { color: #bbbbbb } /* Text.Whitespace */
+.mb { color: #666666 } /* Literal.Number.Bin */
+.mf { color: #666666 } /* Literal.Number.Float */
+.mh { color: #666666 } /* Literal.Number.Hex */
+.mi { color: #666666 } /* Literal.Number.Integer */
+.mo { color: #666666 } /* Literal.Number.Oct */
+.sa { color: #BA2121 } /* Literal.String.Affix */
+.sb { color: #BA2121 } /* Literal.String.Backtick */
+.sc { color: #BA2121 } /* Literal.String.Char */
+.dl { color: #BA2121 } /* Literal.String.Delimiter */
+.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
+.s2 { color: #BA2121 } /* Literal.String.Double */
+.se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
+.sh { color: #BA2121 } /* Literal.String.Heredoc */
+.si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
+.sx { color: #008000 } /* Literal.String.Other */
+.sr { color: #A45A77 } /* Literal.String.Regex */
+.s1 { color: #BA2121 } /* Literal.String.Single */
+.ss { color: #19177C } /* Literal.String.Symbol */
+.bp { color: #008000 } /* Name.Builtin.Pseudo */
+.fm { color: #0000FF } /* Name.Function.Magic */
+.vc { color: #19177C } /* Name.Variable.Class */
+.vg { color: #19177C } /* Name.Variable.Global */
+.vi { color: #19177C } /* Name.Variable.Instance */
+.vm { color: #19177C } /* Name.Variable.Magic */
+.il { color: #666666 } /* Literal.Number.Integer.Long */
diff --git a/site.moon b/site.moon
index 129bbb1..8865234 100644
--- a/site.moon
+++ b/site.moon
@@ -19,11 +19,11 @@ require(rend).cmd = "pandoc --mathjax >"
-- require(rend).cmd = "pandoc --mathjax -f json >"
-- Insert custom renderer in the first position so it will be preferred
-table.insert Site.default_renderers, 1, rend
+-- table.insert Site.default_renderers, 1, rend
-- Remove "pygments" plugin because it conflicts with pandoc syntax highlighting
-Site.default_plugins = for v in *Site.default_plugins
- if v\find "pygments" then continue else v
+-- Site.default_plugins = for v in *Site.default_plugins
+-- if v\find "pygments" then continue else v
-- from https://github.com/leafo/sitegen/blob/v0.2/spec/sitegen_spec.moon#L9-L18
get_files = (path, prefix=path) ->
@@ -118,8 +118,8 @@ sitegen.create =>
} for path in *files
add "index.html", title: "Catalin Mititiuc"
- add "blog.html", title: "Posts", target: "posts/index", template: "blog"
- add_all files_from "docs"
+ -- add "blog.html", title: "Posts", target: "posts/index", template: "blog"
+ -- add_all files_from "docs"
-- replace post markdown yaml headers with moonscript headers
filter "docs", (body) =>
@@ -129,3 +129,5 @@ sitegen.create =>
moonscript_header
copy "app.css"
+ -- copy "pygments.css"
+ copy "moonscript.css"
diff --git a/templates/root.html b/templates/root.html
index 21731aa..c46440e 100644
--- a/templates/root.html
+++ b/templates/root.html
@@ -12,6 +12,7 @@
media="screen"
/>
+
diff --git a/test.moon b/test.moon
new file mode 100644
index 0000000..da5d10b
--- /dev/null
+++ b/test.moon
@@ -0,0 +1,9 @@
+class Thing
+ name: "unknown"
+
+class Person extends Thing
+ say_name: => print "Hel#lo, I am #{@name}!"
+
+with Person!
+ .name = "MoonScript"
+ \say_name!