this repo has no description
1<!DOCTYPE html>
2<html lang=en-QS>
3<meta charset="utf-8">
4<title>Markup2 Test Editor</title>
5
6<!-- TODO: test renderer? at least make sure it doesn't crash -->
7
8<script src=../parse.js></script>
9<script src=../render.js></script>
10<link rel=stylesheet href=../markup.css>
11
12<link rel=stylesheet href=style.css>
13<script src=test.js></script>
14<script src=draw.js></script>
15<style>
16 html, body {
17 position: fixed;
18 overflow: hidden;
19 top: 0;
20 left: 0;
21 right: 0;
22 bottom: 0;
23 }
24 body {
25 display: flex;
26 flex-direction: row;
27 }
28 body > div {
29 width: 50%;
30 display: flex;
31 flex-direction: column;
32 overflow-y: scroll;
33 }
34 textarea {
35 resize: vertical;
36 }
37</style>
38
39<body>
40<div>
41 <button onclick="run()">run tests</button>
42 <hr>
43
44 <textarea id=$input placeholder='markup'></textarea>
45 <div>
46 new test case:
47 <input id=$title placeholder='name'>
48 <button onclick="add_test($title.value, $input.value)">add</button>
49 </div>
50 <div class='Markup' id=$preview style='padding: 5px; border: 1px solid black;'></div>
51 <hr>
52 test definitions: (saved in localstorage)
53 <textarea id=$show_entries style='resize: vertical;height: 200px;'></textarea>
54</div>
55<div>
56 <div id=$output></div>
57</div>
58
59<script>
60 let parser = new Markup_12y2()
61 let renderer = new Markup_Render_Dom()
62
63 $show_entries.value = localStorage.tests || `🟩 text
64abc
65🟩 {"type":"ROOT","tag":"","content":["abc"]}`
66
67 load()
68 run()
69
70 $input.oninput = function() {
71 let tree = parser.parse(this.value)
72 let e = renderer.render(tree)
73 $preview.replaceChildren(e)
74 }
75
76 function load() {
77 localStorage.tests = $show_entries.value // todo: only update if valid
78 Test.load_text($show_entries.value)
79 }
80
81 function run() {
82 load()
83 Test.run_all()
84 $output.replaceChildren(Test.draw_results())
85 }
86
87 //$output.replaceChildren(Test.draw_results())
88 //run()
89
90 function add_test(title, input) {
91 // todo: insert the output results element right away
92
93 input = input.replace(/🟩/g, "?")
94 let tree = parser.parse(input)
95 JSON.stringify(tree) // just to test
96
97 let t = new Test({name: title}, input, clean(tree))
98
99 $show_entries.value += "\n\n"+t.to_entry()
100
101 load()
102 run()
103 }
104</script>