Added F# support and example Added F# support and example
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
diff --git a/components.js b/components.js
index 6664faf..3b92c04 100644
--- a/components.js
+++ b/components.js
@@ -297,6 +297,11 @@ var components = {
"title": "TypeScript",
"require": "javascript",
"owner": "vkbansal"
+ },
+ "fsharp": {
+ "title": "F#",
+ "require": "clike",
+ "owner": "simonreynolds7"
}
},
"plugins": {
diff --git a/components/prism-fsharp.js b/components/prism-fsharp.js
new file mode 100644
index 0000000..51f9402
--- /dev/null
+++ b/components/prism-fsharp.js
@@ -0,0 +1,16 @@
+Prism.languages.fsharp = Prism.languages.extend('clike', {
+ 'comment': [
+ {
+ pattern: /(^|[^\\])\(\*[\w\W]*?\*\)/g,
+ lookbehind: true
+ },
+ {
+ pattern: /(^|[^\\:])\/\/.*?(\r?\n|$)/g,
+ lookbehind: true
+ }
+ ],
+ 'keyword': /\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|let|let!|match|member|module|mutable|namespace|new|not|null|of|open|or|override|private|public|rec|return|return!|select|static|struct|then|to|true|try|type|upcast|use|use!|val|void|when|while|with|yield|yield!|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b/g,
+ 'string': /@?("""|"|')((\\|\n)?.)*?\1(B)?/g,
+ 'preprocessor': /^\s*#.*/gm,
+ 'number': /\b-?(0x)?\d*\.?\d+(y|uy|s|us|l|ul|un|L|UL|F|f|lf|LF|I|M|m)?\b/g
+});
\ No newline at end of file
diff --git a/components/prism-fsharp.min.js b/components/prism-fsharp.min.js
new file mode 100644
index 0000000..d55c5ed
--- /dev/null
+++ b/components/prism-fsharp.min.js
@@ -0,0 +1 @@
+Prism.languages.fsharp=Prism.languages.extend("clike",{comment:[{pattern:/(^|[^\\])\(\*[\w\W]*?\*\)/g,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*?(\r?\n|$)/g,lookbehind:!0}],keyword:/\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|let|let!|match|member|module|mutable|namespace|new|not|null|of|open|or|override|private|public|rec|return|return!|select|static|struct|then|to|true|try|type|upcast|use|use!|val|void|when|while|with|yield|yield!|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b/g,string:/@?("""|"|')((\\|\n)?.)*?\1(B)?/g,preprocessor:/^\s*#.*/gm,number:/\b-?(0x)?\d*\.?\d+(y|uy|s|us|l|ul|un|L|UL|F|f|lf|LF|I|M|m)?\b/g});
\ No newline at end of file
diff --git a/examples/prism-fsharp.html b/examples/prism-fsharp.html
new file mode 100644
index 0000000..2f3c795
--- /dev/null
+++ b/examples/prism-fsharp.html
@@ -0,0 +1,55 @@
+<h1>F#</h1>
+<p>To use this language, use the class "language-fsharp".</p>
+
+<h2>Comments</h2>
+<pre><code>// Single line comment
+(* Multi-line
+comment *)</code></pre>
+
+<h2>Strings</h2>
+<pre><code>"foo \"bar\" baz"
+'foo \'bar\' baz'
+@"Verbatim strings"
+"""Alternate "verbatim" strings"""
+</code></pre>
+
+<h2>Full example</h2>
+<pre><code>// The declaration creates a constructor that takes two values, name and age.
+type Person(name:string, age:int) =
+ // A Person object's age can be changed. The mutable keyword in the
+ // declaration makes that possible.
+ let mutable internalAge = age
+
+ // Declare a second constructor that takes only one argument, a name.
+ // This constructor calls the constructor that requires two arguments,
+ // sending 0 as the value for age.
+ new(name:string) = Person(name, 0)
+
+ // A read-only property.
+ member this.Name = name
+ // A read/write property.
+ member this.Age
+ with get() = internalAge
+ and set(value) = internalAge <- value
+
+ // Instance methods.
+ // Increment the person's age.
+ member this.HasABirthday () = internalAge <- internalAge + 1
+
+ // Check current age against some threshold.
+ member this.IsOfAge targetAge = internalAge >= targetAge
+
+ // Display the person's name and age.
+ override this.ToString () =
+ "Name: " + name + "\n" + "Age: " + (string)internalAge
+</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 */ baz"; "foo // bar";</code></pre>
\ No newline at end of file