Added YAML highlighter
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
diff --git a/components.js b/components.js
index 2ae508f..7be1869 100644
--- a/components.js
+++ b/components.js
@@ -326,6 +326,10 @@ var components = {
"title": "Wiki markup",
"require": "markup",
"owner": "Golmote"
+ },
+ "yaml": {
+ "title": "YAML",
+ "owner": "hason"
}
},
"plugins": {
diff --git a/components/prism-yaml.js b/components/prism-yaml.js
new file mode 100644
index 0000000..6b45e8a
--- /dev/null
+++ b/components/prism-yaml.js
@@ -0,0 +1,44 @@
+Prism.languages.yaml = {
+ 'scalar': {
+ pattern: /([\-:]\s*(![^\s]+)?[ \t]*[|>])[ \t]*(?:(\n[ \t]+)[^\r\n]+(?:\3[^\r\n]+)*)/,
+ lookbehind: true,
+ alias: 'string'
+ },
+ 'comment': /#[^\n]+/,
+ 'key': {
+ pattern: /(\s*[:\-,[{\n?][ \t]*(![^\s]+)?[ \t]*)[^\n{[\]},#]+?(?=\s*:\s)/,
+ lookbehind: true,
+ alias: 'atrule'
+ },
+ 'directive': {
+ pattern: /((^|\n)[ \t]*)%[^\n]+/,
+ lookbehind: true,
+ alias: 'important'
+ },
+ 'datetime': {
+ pattern: /([:\-,[{]\s*(![^\s]+)?[ \t]*)(\d{4}-\d\d?-\d\d?([tT]|[ \t]+)\d\d?:\d{2}:\d{2}(\.\d*)?[ \t]*(Z|[-+]\d\d?(:\d{2})?)?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(:\d{2}(\.\d*)?)?)(?=[ \t]*(\n|$|,|]|}))/,
+ lookbehind: true,
+ alias: 'number'
+ },
+ 'boolean': {
+ pattern: /([:\-,[{]\s*(![^\s]+)?[ \t]*)(true|false)[ \t]*(?=\n|$|,|]|})/i,
+ lookbehind: true,
+ alias: 'important'
+ },
+ 'null': {
+ pattern: /([:\-,[{]\s*(![^\s]+)?[ \t]*)(null|~)[ \t]*(?=\n|$|,|]|})/i,
+ lookbehind: true,
+ alias: 'important'
+ },
+ 'string': {
+ pattern: /([:\-,[{]\s*(![^\s]+)?[ \t]*)("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')(?=[ \t]*(\n|$|,|]|}))/,
+ lookbehind: true
+ },
+ 'number': {
+ pattern: /([:\-,[{]\s*(![^\s]+)?[ \t]*)[+\-]?(0x[\dA-Fa-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)[ \t]*(?=\n|$|,|]|})/i,
+ lookbehind: true
+ },
+ 'tag': /![^\s]+/,
+ 'important': /[&*][\w]+/,
+ 'punctuation': /([:[\]{}\-,|>?]|---|\.\.\.)/
+};
diff --git a/components/prism-yaml.min.js b/components/prism-yaml.min.js
new file mode 100644
index 0000000..2fd09f7
--- /dev/null
+++ b/components/prism-yaml.min.js
@@ -0,0 +1 @@
+Prism.languages.yaml={scalar:{pattern:/([\-:]\s*(![^\s]+)?[ \t]*[|>])[ \t]*(?:(\n[ \t]+)[^\r\n]+(?:\3[^\r\n]+)*)/,lookbehind:!0,alias:"string"},comment:/#[^\n]+/,key:{pattern:/(\s*[:\-,[{\n?][ \t]*(![^\s]+)?[ \t]*)[^\n{[\]},#]+?(?=\s*:\s)/,lookbehind:!0,alias:"atrule"},directive:{pattern:/((^|\n)[ \t]*)%[^\n]+/,lookbehind:!0,alias:"important"},datetime:{pattern:/([:\-,[{]\s*(![^\s]+)?[ \t]*)(\d{4}-\d\d?-\d\d?([tT]|[ \t]+)\d\d?:\d{2}:\d{2}(\.\d*)?[ \t]*(Z|[-+]\d\d?(:\d{2})?)?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(:\d{2}(\.\d*)?)?)(?=[ \t]*(\n|$|,|]|}))/,lookbehind:!0,alias:"number"},"boolean":{pattern:/([:\-,[{]\s*(![^\s]+)?[ \t]*)(true|false)[ \t]*(?=\n|$|,|]|})/i,lookbehind:!0,alias:"important"},"null":{pattern:/([:\-,[{]\s*(![^\s]+)?[ \t]*)(null|~)[ \t]*(?=\n|$|,|]|})/i,lookbehind:!0,alias:"important"},string:{pattern:/([:\-,[{]\s*(![^\s]+)?[ \t]*)("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')(?=[ \t]*(\n|$|,|]|}))/,lookbehind:!0},number:{pattern:/([:\-,[{]\s*(![^\s]+)?[ \t]*)[+\-]?(0x[\dA-Fa-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)[ \t]*(?=\n|$|,|]|})/i,lookbehind:!0},tag:/![^\s]+/,important:/[&*][\w]+/,punctuation:/([:[\]{}\-,|>?]|---|\.\.\.)/};
\ No newline at end of file
diff --git a/examples/prism-yaml.html b/examples/prism-yaml.html
new file mode 100644
index 0000000..14cc5bd
--- /dev/null
+++ b/examples/prism-yaml.html
@@ -0,0 +1,110 @@
+<h1>YAML</h1>
+<p>To use this language, use the class "language-yaml".</p>
+
+<h2>Null and Boolean</h2>
+<pre><code>---
+A null: null
+A null: ~
+Also a null: # Empty
+Not a null: ""
+Booleans: [ true, True, false, FALSE ]
+</code></pre>
+
+<h2>Numbers and timestamps</h2>
+<pre><code>---
+Integers: [ 0, -0, 3, 0o7, 0x3A, -19 ]
+Floats: [ 0., -0.0, .5, 12e03, +12e03, -2E+05 ]
+Also floats: [ .inf, -.Inf, +.INF, .NAN ]
+Timestamps:
+ canonical: 2001-12-15T02:59:43.1Z
+ iso8601: 2001-12-14t21:59:43.10-05:00
+ spaced: 2001-12-14 21:59:43.10 -5
+ date: 2002-12-14
+ times:
+ - 10:53
+ - 10:53:20.53
+</code></pre>
+
+<h2>Strings</h2>
+<pre><code>---
+product: High Heeled "Ruby" Slippers
+description: "Putting on these \"slippers\" is easy."
+address:
+ city: East Centerville
+ street: !!str |
+ 123 Tornado Alley
+ Suite 16
+
+ specialDelivery: >
+ Follow the Yellow Brick
+ Road to the Emerald City.
+ #Pay no attention to the
+ man behind the curtain.
+</code></pre>
+
+<h2>Sequences and maps</h2>
+<pre><code>---
+- Casablanca
+- North by Northwest
+- {
+ name: John Smith, age: 33}
+- name: Mary Smith
+ age: 27
+---
+"name": John Smith
+age: 33
+men: [ John Smith,
+ "Bill Jones" ]
+women:
+ - Mary Smith
+ - "Susan Williams"
+</code></pre>
+
+<h2>Tags</h2>
+<pre><code>---
+!!map {
+ ? !!str friends: !!seq [
+ !!map {
+ ? !!str "age"
+ : !!int 33,
+ ? !!str "name"
+ : !!str "John Smith",
+ }
+ ],
+ men:
+ [ !!str "John Smith", !!str "Bill Jones"]
+}
+</code></pre>
+
+<h2>Full example</h2>
+<pre><code>%YAML 1.2
+--- !<tag:clarkevans.com,2002:invoice>
+invoice: 34843
+date : 2001-01-23
+bill-to: &id001
+ given : Chris
+ family : Dumars
+ address:
+ lines: |
+ 458 Walkman Dr.
+ Suite #292
+ city : Royal Oak
+ state : MI
+ postal : 48046
+ship-to:
+ <<: *id001
+ product:
+ - sku : BL394D
+ quantity : 4
+ description : Basketball
+ price : 450.00
+ - sku : BL4438H
+ quantity : 1
+ description : Super Hoop
+ price : 2392.00
+tax : 251.42
+total: 4443.52
+comments:
+ Late afternoon is best.
+ Backup contact is Nancy
+</code></pre>