Skip to content

Commit b99f368

Browse files
committed
Change to export defineMode
1 parent 9732fce commit b99f368

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

demo/index.html renamed to index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ <h3 class="text-center">Lambda Calculus mode for CodeMirror</h3>
8989
allf = \ f xs . all (map f xs)
9090
</textarea>
9191
</form>
92-
<p class="text-center"><strong>MIME type:</strong> <code>text/lambda-calc</code></p>
92+
<p class="text-center"><strong>MIME type:</strong> <code>text/x-lambdacalc</code></p>
9393
</main>
9494

9595
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.1/codemirror.min.js"></script>
9696
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.1/addon/edit/matchbrackets.min.js"></script>
97-
<script src="../lambdacalc.js"></script>
98-
<script>
97+
<script type="module">
98+
import { defineMode } from "./lambdacalc.js";
99+
defineMode(CodeMirror);
99100
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
100101
lineNumbers: true,
101102
matchBrackets: true,

lambdacalc.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
1-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2-
// Distributed under an MIT license: https://codemirror.net/LICENSE
3-
4-
// Lambda Calculus Mode written by Keldan Chapman (Kacarott on CodeWars)
5-
6-
(function(mod) {
7-
if (typeof exports == "object" && typeof module == "object") // CommonJS
8-
mod(require("../../lib/codemirror"));
9-
else if (typeof define == "function" && define.amd) // AMD
10-
define(["../../lib/codemirror"], mod);
11-
else // Plain browser env
12-
mod(CodeMirror);
13-
})(function(CodeMirror) {
14-
"use strict";
15-
1+
export const defineMode = function(CodeMirror) {
162
CodeMirror.defineMode("lambdacalc", function(_config, modeConfig) {
17-
183
// Modes for different types of symbols
194
const DEFNAME = "variable-2";
205
const EQUALS = "text";
@@ -155,6 +140,5 @@ CodeMirror.defineMode("lambdacalc", function(_config, modeConfig) {
155140

156141
});
157142

158-
CodeMirror.defineMIME("text/x-lambdacalc", "lambdacalculus");
159-
160-
});
143+
CodeMirror.defineMIME("text/x-lambdacalc", "lambdacalc");
144+
};

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@codewars/codemirror-lambda-calculus",
33
"version": "0.1.0",
4+
"type": "module",
45
"description": "CodeMirror mode for Lambda Calculus",
56
"main": "lambdacalc.js",
67
"repository": {

0 commit comments

Comments
 (0)