Search code examples
wordpressmarkdownjekyllliquidkramdown

Code block with Kramdown, modified in Liquid


I want to move my posts from WordPress to Jekyll and i have a problem with code blocks. I wrote code for replacing original formatting tags with Kramdown tags, but the page does not recognize the formatting marks and treats it like text. Here is code:

{{ content | replace: '[code language=”csharp”]', '~~~<br>' | replace: '[/code]', '<br>~~~'  }}

its replacing the original code but it doesn't recognize the formatting pattern. Maybe i need to update it after formation? or is there a method for reformatting markdown text? Or can i perform this operation before converting to HTML? I want to write one method that works for all post.


Solution

  • When you do this replace, it is too late for the Markdown converter to pickup this change.

    To make this work the way you want to do, you would have write a plugin that performs the replace before the Markdown converter runs.

    However, assuming you don't want to use [code] for new posts, it would be much easier to do a one-time search/replace on the Markdown files directly, which you already created from your Wordpress blog.

    i.e. open all files in Notepad++ (or similar text editor), and do a search/replace across all files.