Created
March 9, 2020 19:44
-
-
Save jonsage/53acc4f8dd551aeff609a0137e6e326f to your computer and use it in GitHub Desktop.
Jekyll plugin to prevent liquid syntax being processed inside of code fences
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
# 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