{% comment %} Input {% endcomment %}{% capture _content %}{{ content }}{% endcapture %}{% comment %} Remove redundant closing tags {% endcomment %}{% assign _endings = "html head body li dt dd p rt rp optgroup option colgroup caption thead tbody tfoot tr td th" | split: " " %}{% for _element in _endings %} {% capture _end %}{% endcapture %} {% assign _content = _content | remove: _end %} {% endfor %}{% comment %} Create a variable to match newlines {% endcomment %}{% capture nl %} {% endcapture %}{% comment %} Prepare inline otherwise Liquid won't match, and blow up everything if two elements comes straight after eachother:
{% endcomment %}{% assign _content = _content | replace: '', '' | replace: '', " " %}{% assign _script_befores = _content | split: "" %} {% case _scripts.size %} {% when 2 %} {% assign _script = _scripts.first | replace: "// //", "/*[COMMENT]*/ " | replace: "// //", "/*[COMMENT]*/ " | replace: "// ", "/*[COMMENT]*/ " | replace: " //", "/*[COMMENT]*/ " | replace: " //", "/*[COMMENT]*/ " | replace: "// ", "/*[COMMENT]*/ " | replace: "//", "/*[COMMENT]*/ " | %} {% assign _script_comment_befores = _script | split: "/*[COMMENT]*/ " %}{% for _script_comment_before in _script_comment_befores %} {% assign _script_comment_content = _script_comment_before | split: nl | first %} {% if _script_comment_content %} {% capture _script_comment %}{{ "/*[COMMENT]*/ " }}{{ _script_comment_content }}{{ nl }}{% endcapture %} {% assign _script = _script | remove: _script_comment %} {% endif %} {% endfor %} {% assign _script_comment_befores = _script | split: "/*" %}{% for _script_comment_before in _script_comment_befores %} {% assign _script_comment_content = _script_comment_before | split: "*/" | first %} {% if _script_comment_content %} {% capture _script_comment %}{{ "/*" }}{{ _script_comment_content }}{{ "*/" }}{% endcapture %} {% assign _script = _script | remove: _script_comment %} {% endif %} {% endfor %} {% capture _content %}{{ _content }}