-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
31 lines (30 loc) · 934 Bytes
/
test.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<script src="tracery.js"></script>
<script src="./grammars/obstacles.js"></script>
</head>
<body>
<div id="visualization" style="">
</div>
<script>
var test_gram = create_obstacle_grammar();
function testGrammar(grammar_rules, start, context) {
console.debug(grammar_rules);
let grammar = tracery.createGrammar(grammar_rules);
grammar.clearState();
console.log(grammar)
let message = grammar.flatten(start);
console.log(message);
return message;
}
var a = testGrammar(test_gram, '#intro_obstacle#|#solve_obstacle#');
var split_a = a.split('|')
console.log(a)
console.log(split_a)
var res = document.getElementById('visualization');
res.innerHTML = "<p>" + split_a[0] + "</p><p>" + split_a[1] + "</p>";
</script>
</body>
</html>