Skip to content

Instantly share code, notes, and snippets.

@ketanmistry
Created January 13, 2020 05:03
Show Gist options
  • Save ketanmistry/9f6ee3aeaaaa2c2302839945d2baef04 to your computer and use it in GitHub Desktop.
Save ketanmistry/9f6ee3aeaaaa2c2302839945d2baef04 to your computer and use it in GitHub Desktop.
Shopify parse markdown table within content.
{% comment %}
Parse Markdown table within content.
{% endcomment %}
{% assign page_content = page.content | strip_newlines %}
{% assign page_content = page_content | replace_first: '<p>|', '<table><tr><td>' %}
{% assign page_content = page_content | replace: ' | ', '</td><td>' %}
{% assign page_content = page_content | replace: '&nbsp;| ', '</td><td>' %}
{% assign page_content = page_content | replace: ' |&nbsp;', '</td><td>' %}
{% assign page_content = page_content | replace: '&nbsp;|&nbsp;', '</td><td>' %}
{% assign page_content = page_content | replace: '|</p>', '</td></tr>' %}
{% assign page_content = page_content | replace: '<p>|', '<tr><td>' %}
{% assign page_content = page_content | replace: '</td></tr><p>', '</td></tr></table>' %}
{% assign page_content = page_content | replace: '</table></p>', '</table>'%}
{% comment %}
Output content.
{% endcomment %}
{{ page_content}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment