(options, spec)
| 2219 | // Given a mode spec (anything that resolveMode accepts), find and |
| 2220 | // initialize an actual mode object. |
| 2221 | function getMode(options, spec) { |
| 2222 | spec = resolveMode(spec) |
| 2223 | var mfactory = modes[spec.name] |
| 2224 | if (!mfactory) { |
| 2225 | return getMode(options, "text/plain") |
| 2226 | } |
| 2227 | var modeObj = mfactory(options, spec) |
| 2228 | if (modeExtensions.hasOwnProperty(spec.name)) { |
| 2229 | var exts = modeExtensions[spec.name] |
| 2230 | for (var prop in exts) { |
| 2231 | if (!exts.hasOwnProperty(prop)) { |
| 2232 | continue |
| 2233 | } |
| 2234 | if (modeObj.hasOwnProperty(prop)) { |
| 2235 | modeObj["_" + prop] = modeObj[prop] |
| 2236 | } |
| 2237 | modeObj[prop] = exts[prop] |
| 2238 | } |
| 2239 | } |
| 2240 | modeObj.name = spec.name |
| 2241 | if (spec.helperType) { |
| 2242 | modeObj.helperType = spec.helperType |
| 2243 | } |
| 2244 | if (spec.modeProps) { |
| 2245 | for (var prop$1 in spec.modeProps) { |
| 2246 | modeObj[prop$1] = spec.modeProps[prop$1] |
| 2247 | } |
| 2248 | } |
| 2249 | |
| 2250 | return modeObj |
| 2251 | } |
| 2252 | |
| 2253 | // This can be used to attach properties to mode objects from |
| 2254 | // outside the actual mode definition. |
no test coverage detected