Skip to content

Instantly share code, notes, and snippets.

@jonsage
Created March 9, 2020 19:44
Show Gist options
  • Save jonsage/53acc4f8dd551aeff609a0137e6e326f to your computer and use it in GitHub Desktop.
Save jonsage/53acc4f8dd551aeff609a0137e6e326f to your computer and use it in GitHub Desktop.
Jekyll plugin to prevent liquid syntax being processed inside of code fences
# Prevents liquid syntax being processed inside of code fences
Jekyll::Hooks.register :documents, :pre_render do |page, payload|
docExt = page.extname.tr('.', '')
# only process if we deal with a markdown file
if payload['site']['markdown_ext'].include? docExt
page.content.gsub!(/^(\s*?)(```[\s\S]+?```)(\s*?)$/, '\1{% raw %}\2{% endraw %}\3')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment