I made a post a month or so ago about changing the standard markdown image to a liquid tag without explicitly using the liquid tag Here
I got a very helpful code snippet which does the job perfectly on the actual post markdowns.
Jekyll::Hooks.register :posts, :pre_render do |post, payload|
docExt = post.extname.tr('.', '')
# only process if we deal with a markdown file
if payload['site']['markdown_ext'].include? docExt
newContent = post.content.gsub(/\!\[(.+)\]\((.+)\)/, '{% picture \2 alt="\1" %}')
post.content = newContent
end
end
However, I have noticed that the post.excerpt
is already converted to html at the point that the hook is called on the posts. This means that any changes the plugin makes to the post’s markdown is not reflected in the excerpt at all, I’ve tried playing around with the specific hooks and when they are called but I can’t find one that works.
Can anyone help with the hook that I need to access the excerpt’s markdown before it is converted to html, so that I can apply the same script to it?