Last active
April 28, 2024 11:16
-
-
Save mmistakes/77c68fbb07731a456805a7b473f47841 to your computer and use it in GitHub Desktop.
Jekyll plugin to replace Markdown images eg. `` with `{% picture %}` tag
This file contains hidden or 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
# Description: Jekyll plugin to replace Markdown image syntax with {% picture %} tag for crafting responsive images | |
# place in /_plugins/ | |
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 default \2 alt="\1" %}') | |
post.content = newContent | |
end | |
end |
How can i use it in bettercap ? through proxy
I'm using this in the year of our lord 2022. Thanks @mmistakes! 🙌
I changed the regex to
newContent = post.content.gsub(/\!\[(.*)\]\((.+)\)/, '{% picture default \2 alt="\1" %}')
to allow it to work even if the alt text is the empty string.
I've done some more work to make this plugin more robust and readable. See: https://gist.github.com/tadamcz/869802c919c72172486f219751904108
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This version works for collections in addition to posts (e.g. here made to work with Jekyll Picture Tag):