This repository has been archived by the owner on Apr 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathshowerify.html
125 lines (112 loc) · 6.89 KB
/
showerify.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{% capture strip_whitespace %}
{% include setup.md %}
{% assign items = showerify_input | split:'<h1' %}
{% for item in items %}
{% assign subitems = item | split:'</h1>' %}
{% assign subsubitems = subitems[0] %}
{% capture subsubitems2 %}{{ subsubitems }}{% endcapture %}
{% assign subsubitems2 = subsubitems2 | split: '>' %}
{% assign lol = subsubitems2[0] | append:">" %}
{% capture supertitle %}{{ subsubitems | remove_first:lol }}{% endcapture %}
{% endfor %}
{% assign flag = false %}
{% for item in items %}
{% capture h1_attrs %}{{ item | split:'>' | first }}{% endcapture %}
{% if flag != false %}
{% capture showerify_middle %}<section{{ h1_attrs | replace_first:'class="','class="slide ' }}{% unless h1_attrs contains 'class' %} class="slide cover"{% endunless %}><div><h2{% endcapture %}
{% assign slides = item | remove_first:h1_attrs | replace_first:'</h1>','</h2>' | split: '<h2' %}
{% assign flag = false %}
{% for slide in slides %}
{% capture slide_attrs %}{{ slide | split:'>' | first }}{% endcapture %}
<!-- Looking for strong in header for shout -->
{% capture slide_header_content %}^BEGIN^{{ slide | remove_first:slide_attrs | split:'</h2>' | first }}$END${% endcapture %}
{% assign slide_extra_class = '' %}
{% if slide_header_content contains '^BEGIN^><strong>' and slide_header_content contains '</strong>$END$' %}
{% assign slide_extra_class = ' shout' %}
{% endif %}
{% if flag == false %}
{% capture showerify_middle %}{{ showerify_middle }}{{ slide }}{% endcapture %}
{% assign flag = true %}
{% else %}
{% capture showerify_middle %}{{ showerify_middle }}</div></section>
<section class="slide{{ slide_extra_class }}"{{ slide_attrs }}><div><h2{% endcapture %}
{% assign newslide = slide | remove_first:slide_attrs %}
{% if slide_extra_class %}
{% assign newslide = newslide | replace_first:'><strong>','>' %}
{% assign newslide = newslide | replace_first:'</strong></h2>','</h2>' %}
{% endif %}
{% capture showerify_middle %}{{ showerify_middle }}{{ newslide }}{% endcapture %}
{% endif %}
{% endfor %}
{% capture showerify_middle %}{{ showerify_middle }}</div></section>{% endcapture %}
{% else %}
{% assign flag = true %}
{% endif %}
{% endfor %}
<!-- There is a difference between Liquid 1.4.1 and 1.5.0 in replace syntax, and in 1.4.1 you can't chain the one that is only there in 1.5.0, so multiple assigns there -->
{% assign showerify_middle = showerify_middle | replace:'class="slide" class="','class="slide ' %}
{% assign showerify_middle = showerify_middle | replace:'</mark>','</mark>' %}
{% assign showerify_middle = showerify_middle | replace:'<mark>','<mark>' %}
{% assign showerify_middle = showerify_middle | replace:'<mark class="next">','<mark class="next">' %}
{% assign showerify_middle = showerify_middle | replace:'<mark class="comment">','<mark class="comment">' %}
{% assign showerify_middle = showerify_middle | replace:'<mark class="important">','<mark class="important">' %}
<!-- Replacing inline “comment” with <footer> -->
{% assign footers = showerify_middle | split:'<p>// ' %}
{% assign iteration = 0 %}
{% for footer in footers %}
{% if iteration > 0 %}
{% assign footer_content = footer | split:'</p>' | first %}
{% capture footer_oldcontent %}<p>// {{ footer_content }}</p>{% endcapture %}
{% capture footer_newcontent %}<footer>{{ footer_content }}</footer>{% endcapture %}
{% assign showerify_middle = showerify_middle | replace_first:footer_oldcontent,footer_newcontent %}
{% endif %}
{% assign iteration = iteration | plus:1 %}
{% endfor %}
<!-- The same thing, but this time for comment without the space -->
{% assign footers = showerify_middle | split:'<p>//' %}
{% assign iteration = 0 %}
{% for footer in footers %}
{% if iteration > 0 %}
{% assign footer_content = footer | split:'</p>' | first %}
{% capture footer_oldcontent %}<p>//{{ footer_content }}</p>{% endcapture %}
{% capture footer_newcontent %}<footer>{{ footer_content }}</footer>{% endcapture %}
{% assign showerify_middle = showerify_middle | replace_first:footer_oldcontent,footer_newcontent %}
{% endif %}
{% assign iteration = iteration | plus:1 %}
{% endfor %}
<!-- Code with line-numbers -->
{% if line_numbers %}
{% assign code_blocks = showerify_middle | split:'<pre><code>' %}
{% assign iteration = 0 %}
{% for code_block in code_blocks %}
{% if iteration > 0 %}
{% assign code_block_content = code_block | split:'</code></pre>' | first %}
{% capture code_block_oldcontent %}<pre><code>{{ code_block_content }}</code></pre>{% endcapture %}
{% assign code_block_newcontent = code_block_oldcontent | newline_to_br | strip_newlines | replace:'<br />','</code><code>' %}
{% assign code_block_newcontent = code_block_newcontent | replace:'<code></code></pre>','</pre>' %}
{% assign code_block_newcontent = code_block_newcontent | replace:'<code></code>','<code> </code>' %}
{% assign showerify_middle = showerify_middle | replace_first:code_block_oldcontent,code_block_newcontent %}
{% endif %}
{% assign iteration = iteration | plus:1 %}
{% endfor %}
{% endif %}
<!-- Adding .next to list items -->
{% assign showerify_middle = showerify_middle | replace:'>...',' class="next">' %}
{% assign showerify_middle = showerify_middle | replace:'>…',' class="next">' %}
{% assign showerify_middle = showerify_middle | replace:'>…',' class="next">' %}
{% assign showerify_middle = showerify_middle | replace:' class="next"> ',' class="next">' %}
{% assign showerify_middle = showerify_middle | replace:'>\...','>...' %}
{% assign showerify_middle = showerify_middle | replace:'>\…','>…' %}
{% assign showerify_middle = showerify_middle | replace:'>\…','>…' %}
<!-- By default all the simple `<th>` are for cols -->
{% assign showerify_middle = showerify_middle | replace:'<th>','<th scope="col">' %}
<!-- And all the td starting/ending with asteriks are row ths -->
{% assign showerify_middle = showerify_middle | replace:'<td>* ','<th scope="row">' %}
{% assign showerify_middle = showerify_middle | replace:' *</td>','</th>' %}
<!-- Kramdown mailto problem -->
{% assign showerify_middle = showerify_middle | replace:'href="mail:','href="mailto:' %}
<!-- Prototype of #3, need to split things here -->
<!-- is there a way to declare <hr/> with classes/attributes? -->
{% assign showerify_middle = showerify_middle | replace:'<hr />','</div></section><section class="slide"><div>' %}
{% capture showerify_output %}{{ showerify_middle }}{% endcapture %}
{% endcapture %}