|
1 | 1 | {% comment %}
|
2 |
| - Version 2018-08-08 |
| 2 | + Version 2019-08-06 |
3 | 3 | https://github.com/kevinlin1/jekyll-python-tutor
|
4 | 4 |
|
5 | 5 | Liquid template for generating Java Visualizer embeds.
|
|
12 | 12 | }
|
13 | 13 | }
|
14 | 14 | {%- endcapture -%}
|
15 |
| - {% include java_visualizer.html |
16 |
| - embed=true caption="Hello, world!" code=HelloWorld |
17 |
| - height="480px" curInstr="0" args='["arg1", ...]' stdin="stdin" %} |
| 15 | + {% include java_visualizer.html code=HelloWorld caption="Hello, world!" %} |
| 16 | + |
| 17 | + Advanced usage: |
| 18 | + {%- capture HelloWorld -%} |
| 19 | + public class HelloWorld { |
| 20 | + public static void main(String[] args) { |
| 21 | + System.out.println("Hello, world!"); |
| 22 | + } |
| 23 | + } |
| 24 | + {%- endcapture -%} |
| 25 | + {% include java_visualizer.html code=HelloWorld caption="Hello, world!" |
| 26 | + label="Visualize Code" curInstr="0" args='["arg1", ...]' stdin="stdin" %} |
18 | 27 | {% endcomment %}
|
19 | 28 |
|
20 |
| -{% assign height = include.height | default: '564px' %} |
| 29 | +{% assign code = include.code | default: '' %} |
| 30 | +{% assign caption = include.caption | default: '' %} |
| 31 | +{% assign label = include.label | default: 'Visualize Code' %} |
| 32 | +{% assign class = include.class | default: 'btn' %} |
21 | 33 | {% assign curInstr = include.curInstr | default: 0 %}
|
22 | 34 | {% assign args = include.args | default: '[]' %}
|
23 | 35 | {% assign stdin = include.stdin | default: '' %}
|
24 |
| -{% assign code = include.code | default: '' %} |
25 |
| -{% assign caption = include.caption | default: '' %} |
26 |
| -{% assign embed = include.embed | default: false %} |
27 | 36 |
|
28 |
| -{% if embed %} |
29 |
| -{% capture data %} |
30 |
| -{ |
31 |
| -"user_script":"{{ code | replace: '"', '\"' | newline_to_br | replace: '<br />', '\n' }}", |
32 |
| -"options":{ |
33 |
| -"showStringsAsValues":false, |
34 |
| -"showAllFields":false |
35 |
| -}, |
36 |
| -"args":{{ args }}, |
37 |
| -"stdin":"{{ stdin }}" |
38 |
| -} |
39 |
| -{% endcapture %} |
40 |
| -{% assign data = data |
41 |
| - | strip_newlines |
42 |
| - | uri_escape |
43 |
| - | replace: '#', '%23' |
44 |
| - | replace: '$', '%24' |
45 |
| - | replace: '&', '%26' |
46 |
| - | replace: '+', '%2B' |
47 |
| - | replace: ',', '%2C' |
48 |
| - | replace: '/', '%2F' |
49 |
| - | replace: ':', '%3A' |
50 |
| - | replace: ';', '%3B' |
51 |
| - | replace: '=', '%3D' |
52 |
| - | replace: '?', '%3F' |
53 |
| - | replace: '@', '%40' |
54 |
| - | replace: '[', '%5B' |
55 |
| - | replace: ']', '%5D' |
56 |
| -%} |
57 |
| -{% else %} |
58 | 37 | {% capture codeBlock %}
|
59 | 38 | ```java
|
60 | 39 | {{ code }}
|
61 | 40 | ```
|
62 | 41 | {% endcapture %}
|
63 | 42 | {% assign codeBlock = codeBlock | markdownify %}
|
64 |
| -{% endif %} |
65 | 43 |
|
| 44 | +{% if label %} |
66 | 45 | <figure>
|
67 |
| - {% if embed %} |
68 |
| - <iframe style="width: 100%; height: {{ height }}; border: 0;" |
69 |
| - 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"> |
70 |
| - </iframe> |
71 |
| - {% else %} |
72 | 46 | {{ codeBlock }}
|
73 |
| - {% endif %} |
74 |
| - {% if caption %} |
75 | 47 | <figcaption>
|
76 | 48 | {{ caption }}
|
77 |
| - <div class="tag-list"> |
78 |
| - <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 }}"> |
79 |
| - Visualize Code |
80 |
| - </a> |
81 |
| - </div> |
| 49 | + <a class="{{ class }}" target="_blank" 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 }}"> |
| 50 | + {{ label }} |
| 51 | + </a> |
82 | 52 | </figcaption>
|
83 |
| - {% endif %} |
84 | 53 | </figure>
|
| 54 | +{% else %} |
| 55 | +{{ codeBlock }} |
| 56 | +{% endif %} |
0 commit comments