|
2 | 2 | import { Play } from "lucide-svelte"; |
3 | 3 | import { basicSetup, EditorView } from "codemirror"; |
4 | 4 | import { EditorState, Compartment } from "@codemirror/state" |
| 5 | + import { HighlightStyle, syntaxHighlighting, bracketMatching, indentUnit } from "@codemirror/language" |
| 6 | + import { tags } from "@lezer/highlight" |
| 7 | + import { keymap } from "@codemirror/view"; |
| 8 | + import { indentWithTab } from "@codemirror/commands"; |
| 9 | + import { closeBrackets, closeBracketsKeymap } from "@codemirror/autocomplete"; |
| 10 | +
|
5 | 11 | import { onMount, onDestroy } from "svelte"; |
| 12 | + import { AnsiUp } from "ansi_up"; |
6 | 13 |
|
7 | 14 | import Navbar from '$lib/navbar.svelte'; |
8 | 15 | import { getLesson, getNext, getPrevious } from '$lib/tour/data'; |
9 | | - import { AnsiUp } from "ansi_up"; |
| 16 | + import moduSyntax from "$lib/moduSyntax.js"; |
10 | 17 |
|
11 | 18 | let slug: string; |
12 | 19 |
|
|
21 | 28 | doc: "", |
22 | 29 | extensions: [ |
23 | 30 | basicSetup, |
24 | | - tabsize.of(EditorState.tabSize.of(4)), |
| 31 | + EditorState.tabSize.of(4), |
| 32 | + indentUnit.of(" "), |
| 33 | + language.of(moduSyntax), |
| 34 | + keymap.of([indentWithTab, ...closeBracketsKeymap]), |
| 35 | + closeBrackets(), |
| 36 | + bracketMatching(), |
25 | 37 | EditorView.theme({ |
26 | 38 | "&": { |
27 | 39 | color: "#fbf1c7", |
|
53 | 65 | border: "none", |
54 | 66 | }, |
55 | 67 |
|
56 | | - }, { dark: true }) |
| 68 | + }, { dark: true }), |
| 69 | + syntaxHighlighting(HighlightStyle.define([ |
| 70 | + { tag: tags.string, color: "#a6e3a1" }, |
| 71 | + { tag: tags.keyword, color: "#cba6f7" }, |
| 72 | + { tag: tags.atom, color: "#f38ba8" }, |
| 73 | + { tag: tags.escape, color: "#f5c2e7" }, |
| 74 | + { tag: tags.comment, color: "#a89984" }, |
| 75 | + { tag: tags.number, color: "#fab387" }, |
| 76 | + { tag: tags.float, color: "#fab387" }, |
| 77 | + { tag: tags.operator, color: "#89dceb" }, |
| 78 | + { tag: tags.brace, color: "#a89984" }, |
| 79 | + { tag: tags.bool, color: "#89b4fa" } |
| 80 | + ])), |
57 | 81 | ] |
58 | 82 | }); |
59 | 83 |
|
|
94 | 118 |
|
95 | 119 | run(); // run code on load |
96 | 120 | } |
97 | | -
|
98 | | - console.log(lesson); |
99 | 121 | })(); |
100 | 122 | } |
101 | 123 | } |
|
126 | 148 | <div class="prose max-w-none border border-bg2 py-2 px-4 rounded-lg flex-1">{@html html}</div> |
127 | 149 | <div class="mt-6 text-center"> |
128 | 150 | <a href={getPrevious(slug)} class={`text-blue hover:underline ${!getPrevious(slug) && "opacity-50 cursor-not-allowed"}`}>< previous</a> |
129 | | - <span class="mx-2 text-fg2">—</span> |
| 151 | + <span class="mx-2 text-[#7c6d67]">—</span> |
130 | 152 | <a href={getNext(slug)} class={`text-blue hover:underline ${!getNext(slug) && "opacity-50 cursor-not-allowed"}`}>next ></a> |
131 | 153 | </div> |
132 | 154 | </div> |
|
0 commit comments