example.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. {% assign code = code | replace_regex: '// @formatter:(off|on)', '' %}
  2. {% assign demo-code = code %}
  3. {% assign demo-code = demo-code | replace_regex: '\{% (end)?hide %\}', '' %}
  4. {% assign demo-code = demo-code | replace_regex: 'href="#"', 'href="javascript:void(0)"' %}
  5. <div class="example no_toc_section{% if include.centered %} example-centered{% endif %}{% if include.columns or include.light %} example-bg{% endif %}">
  6. <div class="example-content">
  7. {% if include.max-width %}<div style="max-width: {{ include.max-width }}">{% endif %}
  8. {% if include.columns %}<div class="example-column example-column-{{ include.columns }}">{% endif %}
  9. {% if include.modal %}<div class="example-modal-backdrop"></div>{% endif %}
  10. {% if include.wrapper %}<div class="{{ include.wrapper }}">{% endif %}
  11. {{ demo-code }}
  12. {% if include.wrapper %}</div>{% endif %}
  13. {% if include.columns %}</div>{% endif %}
  14. {% if include.max-width %}</div>{% endif %}
  15. </div>
  16. </div>
  17. {% assign code = code | strip %}
  18. {% capture new_line %}
  19. {% endcapture %}
  20. {% assign code = code | replace_regex: "\n\n+", new_line %}
  21. {% unless include.show-svg %}
  22. {% assign code = code | replace_regex: '<svg[^>]*class="icon ([^"]+)"[^>]*>.*?<\/svg>', '<!-- SVG icon code with class="\1" -->' %}
  23. {% assign code = code | replace_regex: '<svg[^>]*>.*?<\/svg>', '<!-- SVG icon code -->' %}
  24. {% endunless %}
  25. {% assign code = code | replace_regex: 'url\(([^\)]+)\)', 'url(...)' %}
  26. {% assign code = code | replace_regex: 'src="([^"]+)"', 'src="..."' %}
  27. {% assign code = code | replace_regex: 'href="([^#][^"]+)"', 'href="#"' %}
  28. {% assign code = code | replace_regex: '\{% hide %\}.*?\{% endhide %\}', '' %}
  29. {% assign code = code | htmlbeautifier %}
  30. <div class="example-code">
  31. {% highlight html %}{{ code }}{% endhighlight %}
  32. </div>