Search code examples
markdownjekyll

How to write the '|' character using Jekyll and Markdown?


I am hosting a Jekyll Blog on Github and write my posts with Markdown. When using the '|' character, I do it the following way:

O = {x ∈ Z+ | x is odd and x < 10}

The page then shows:

O = {x ∈ Z+ x is odd and x < 10}

I have tried this but it doesn't work:

{% raw %}
O = {x ∈ Z+ | x is odd and x < 10}
{% endraw %}

How can I tell Markdown to not escape the '|' character?


Solution

  • If you look at the generated HTML you will see it is being interpreted as a table by Kramdown (which is the default Markdown processor in Jekyll). The easiest fix is to escape it with a backslash:

    O = {x ∈ Z+ \| x is odd and x < 10}
    

    Alternatively you could also use a different Markdown processor, e.g. Redcarpet (in your _config.yml):

    markdown: redcarpet
    

    Or you could keep using Kramdown, but change the parser to one that doesn’t support tables, e.g. the plain Markdown parser (again in your _config.yml):

    kramdown:
      input: markdown