Add support for Prolog
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
diff --git a/components.js b/components.js
index 919b3c1..47dceeb 100644
--- a/components.js
+++ b/components.js
@@ -254,6 +254,10 @@ var components = {
"title": "PowerShell",
"owner": "nauzilus"
},
+ "prolog": {
+ "title": "Prolog",
+ "owner": "Golmote"
+ },
"python": {
"title": "Python",
"owner": "multipetros"
diff --git a/components/prism-prolog.js b/components/prism-prolog.js
new file mode 100644
index 0000000..38dc983
--- /dev/null
+++ b/components/prism-prolog.js
@@ -0,0 +1,16 @@
+Prism.languages.prolog = {
+ // Syntax depends on the implementation
+ 'comment': [
+ /%.+/,
+ /\/\*[\s\S]*?\*\//
+ ],
+ // Depending on the implementation, strings may allow escaped newlines and quote-escape
+ 'string': /(["'])(?:\1\1|\\[\s\S]|(?!\1).)*\1/,
+ 'builtin': /\b(?:fx|fy|xf[xy]?|yfx?)\b/,
+ 'variable': /\b[A-Z_]\w*/,
+ // FIXME: Should we list all null-ary predicates (not followed by a parenthesis) like halt, trace, etc.?
+ 'function': /\b[a-z]\w*(?:(?=\()|\/\d+)/,
+ 'number': /\b\d+\.?\d*/,
+ 'operator': /[:\\=><\-?*@\/;+^|!$.]+|\b(?:is|mod|not|xor)\b/,
+ 'punctuation': /[(){}\[\],]/
+};
\ No newline at end of file
diff --git a/components/prism-prolog.min.js b/components/prism-prolog.min.js
new file mode 100644
index 0000000..4db8e9e
--- /dev/null
+++ b/components/prism-prolog.min.js
@@ -0,0 +1 @@
+Prism.languages.prolog={comment:[/%.+/,/\/\*[\s\S]*?\*\//],string:/(["'])(?:\1\1|\\[\s\S]|(?!\1).)*\1/,builtin:/\b(?:fx|fy|xf[xy]?|yfx?)\b/,variable:/\b[A-Z_]\w*/,"function":/\b[a-z]\w*(?:(?=\()|\/\d+)/,number:/\b\d+\.?\d*/,operator:/[:\\=><\-?*@\/;+^|!$.]+|\b(?:is|mod|not|xor)\b/,punctuation:/[(){}\[\],]/};
\ No newline at end of file
diff --git a/examples/prism-prolog.html b/examples/prism-prolog.html
new file mode 100644
index 0000000..3234885
--- /dev/null
+++ b/examples/prism-prolog.html
@@ -0,0 +1,53 @@
+<h1>Prolog</h1>
+<p>To use this language, use the class "language-prolog".</p>
+
+<h2>Comments</h2>
+<pre><code>% This is a comment
+/* This is a
+multi-line comment */</code></pre>
+
+<h2>Numbers</h2>
+<pre><code>42
+3.1415</code></pre>
+
+<h2>Strings</h2>
+<pre><code>"This is a string."
+"This is a string \
+on multiple lines."
+"A string with \"quotes\" in it."
+"Another string with ""quotes"" in it."</code></pre>
+
+<h2>Example</h2>
+<pre><code>:- dynamic fibo/2.
+fibo(0, 1). fibo(1, 1).
+fibo(N, F) :-
+N >= 2, N1 is N - 1, N2 is N - 2,
+fibo(N1, F1), fibo(N2, F2), F is F1 + F2,
+assert(fibo(N,F):-!). % assert as first clause</code></pre>
+
+<h2>Known failures</h2>
+<p>There are certain edge cases where Prism will fail.
+ There are always such cases in every regex-based syntax highlighter.
+ However, Prism dares to be open and honest about them.
+ If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
+</p>
+
+<h3>Comment-like substrings</h3>
+<pre><code>"foo % bar"</code></pre>
+
+<h3>% inside a quoted atom</h3>
+<pre><code>'foo % bar'</code></pre>
+
+<h3>Null-ary predicates are not highlighted</h3>
+<pre><code>halt.
+trace.
+
+:- if(test1).
+section_1.
+:- elif(test2).
+section_2.
+:- elif(test3).
+section_3.
+:- else.
+section_else.
+:- endif.</code></pre>