Created
January 13, 2020 05:03
-
-
Save ketanmistry/9f6ee3aeaaaa2c2302839945d2baef04 to your computer and use it in GitHub Desktop.
Shopify parse markdown table within content.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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: ' | ', '</td><td>' %} | |
{% assign page_content = page_content | replace: ' | ', '</td><td>' %} | |
{% assign page_content = page_content | replace: ' | ', '</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