example.html 1.9 KB
Newer Older
C
codecalm 已提交
1
{% assign demo-code = code %}
C
codecalm 已提交
2
{% assign demo-code = demo-code | replace_regex: '\{% (end)?hide %\}', '' %}
C
codecalm 已提交
3
{% assign demo-code = demo-code | replace_regex: 'href="#"', 'href="javascript:void(0)"' %}
C
codecalm 已提交
4

C
codecalm 已提交
5
<div class="example no_toc_section{% if include.centered %} example-centered{% endif %}{% if include.columns or include.light %} example-bg{% endif %}">
C
codecalm 已提交
6
	<div class="example-content">
C
codecalm 已提交
7
		{% if include.max-width %}<div style="max-width: {{ include.max-width }}">{% endif %}
C
codecalm 已提交
8
		{% if include.columns %}<div class="example-column example-column-{{ include.columns }}">{% endif %}
C
codecalm 已提交
9
		{% if include.modal %}<div class="example-modal-backdrop"></div>{% endif %}
C
codecalm 已提交
10
		{% if include.wrapper %}<div class="{{ include.wrapper }}">{% endif %}
C
codecalm 已提交
11

C
codecalm 已提交
12
		{{ demo-code }}
C
codecalm 已提交
13 14

		{% if include.wrapper %}</div>{% endif %}
C
codecalm 已提交
15
		{% if include.columns %}</div>{% endif %}
C
codecalm 已提交
16
		{% if include.max-width %}</div>{% endif %}
C
codecalm 已提交
17 18 19
	</div>
</div>

C
codecalm 已提交
20 21 22 23 24 25 26 27 28 29 30 31

{% capture html %}
{{ code }}

{% removeemptylines %}
{{ site.captured_global.scripts | last }}
{% endremoveemptylines %}
{% endcapture %}

{% assign html = html | strip %}
{% assign html = html | replace_regex: '// @formatter:(off|on)', '' %}

C
codecalm 已提交
32 33
{% capture new_line %}
{% endcapture %}
C
codecalm 已提交
34
{% assign html = html | replace_regex: "\n\n+", new_line %}
C
codecalm 已提交
35 36

{% unless include.show-svg %}
C
codecalm 已提交
37 38
{% assign html = html | replace_regex: '<svg[^>]*class="icon ([^"]+)"[^>]*>.*?<\/svg>', '<!-- SVG icon code with class="\1" -->' %}
{% assign html = html | replace_regex: '<svg[^>]*>.*?<\/svg>', '<!-- SVG icon code -->' %}
C
codecalm 已提交
39 40
{% endunless %}

C
codecalm 已提交
41 42 43 44 45 46
{% assign html = html | replace_regex: 'url\(([^\)]+)\)', 'url(...)' %}
{% assign html = html | replace_regex: 'src="([^"]+)"', 'src="..."' %}
{% assign html = html | replace_regex: 'href="([^#][^"]+)"', 'href="#"' %}
{% assign html = html | replace_regex: '\{% hide %\}.*?\{% endhide %\}', '' %}

{% assign html = html | htmlbeautifier %}
C
codecalm 已提交
47 48

<div class="example-code">
C
codecalm 已提交
49
	{% highlight html %}{{ html }}{% endhighlight %}
C
codecalm 已提交
50
</div>