{% 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 %}{{ _element }}>{% 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: "{{ _scripts.last }}{% endcapture %} {% when 1 %} {% capture _content %}{{ _content }}{{ _scripts.last }}{% endcapture %} {% endcase %} {% endfor %}{% comment %} Cleanup - There is an 'missing semicolon' issue with Shopify's Enhanced Ecommerce for Google Analytics, which gets corrected here as well. - There is an 'missing semicolon' issue with Shopify's inline Admin Panel script, which gets corrected here as well. {% endcomment %}{% assign _content = _content | replace: '