-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_visualizer.html
More file actions
80 lines (76 loc) · 2.39 KB
/
Copy pathjava_visualizer.html
File metadata and controls
80 lines (76 loc) · 2.39 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{% comment %}
Liquid template for generating Java Visualizer embeds.
Usage:
{%- capture HelloWorld -%}
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
{%- endcapture -%}
{% include java_visualizer.html
embed=true caption="Hello, world!" code=HelloWorld
height="480px" curInstr="0" args='["arg1", ...]' stdin="stdin" %}
{% endcomment %}
{% assign height = include.height | default: '564px' %}
{% assign curInstr = include.curInstr | default: 0 %}
{% assign args = include.args | default: '[]' %}
{% assign stdin = include.stdin | default: '' %}
{% assign code = include.code | default: '' %}
{% assign caption = include.caption | default: '' %}
{% if include.embed %}
{% capture data %}
{
"user_script":"{{ code | replace: '"', '\"' | newline_to_br | replace: '<br />', '\n' }}",
"options":{
"showStringsAsValues":false,
"showAllFields":false
},
"args":{{ args }},
"stdin":"{{ stdin }}"
}
{% endcapture %}
{% assign data = data
| strip_newlines
| uri_escape
| replace: '#', '%23'
| replace: '$', '%24'
| replace: '&', '%26'
| replace: '+', '%2B'
| replace: ',', '%2C'
| replace: '/', '%2F'
| replace: ':', '%3A'
| replace: ';', '%3B'
| replace: '=', '%3D'
| replace: '?', '%3F'
| replace: '@', '%40'
| replace: '[', '%5B'
| replace: ']', '%5D'
%}
{% else %}
{% capture codeBlock %}
```java
{{ code }}
```
{% endcapture %}
{% assign codeBlock = codeBlock | markdownify %}
{% endif %}
<figure>
{% if include.embed %}
<iframe style="width: 100%; height: {{ height }}; border: 0;"
src="https://cscircles.cemc.uwaterloo.ca/java_visualize/iframe-embed.html#data={{ data }}&cumulative=true&heapPrimitives=false&drawParentPointers=false&textReferences=false&showOnlyOutputs=false&py=3&curInstr={{ curInstr }}&resizeContainer=true&highlightLines=true&rightStdout=true">
</iframe>
{% else %}
{{ codeBlock }}
{% endif %}
{% if caption %}
<figcaption>
{{ caption }}
<div class="tag-list">
<a class="button" target="_blank" rel="noreferrer" href="https://cscircles.cemc.uwaterloo.ca/java_visualize/#code={{ code | url_encode }}&mode=edit&showStringsAsObjects=&disableNesting=&args={{ args | url_encode }}&stdin={{ stdin | url_encode }}&curInstr={{ curInstr }}">
Visualize Code
</a>
</div>
</figcaption>
{% endif %}
</figure>