Created
February 5, 2020 15:44
-
-
Save harper357/c25b00fa95273c1267c2012de6ca1785 to your computer and use it in GitHub Desktop.
Jekyll plugin to replace Markdown code blocks (for mermaid syntax)
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
# modified from https://gist.github.com/mmistakes/77c68fbb07731a456805a7b473f47841 | |
# Description: Jekyll plugin to replace Markdown code blocks (for mermaid syntax) with <div class="mermaid"> tag for crafting mermaid charts with minimal headache | |
# 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(/```mermaid([^`]+?)```/, '<div class="mermaid">\1</div>') | |
post.content = newContent | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment