Last active
May 21, 2018 11:51
-
-
Save drosenstark/21b3d7966cc7a0c3056d0776ff7ab8dd to your computer and use it in GitHub Desktop.
Convert all Mermaid Markdown files (mermaid-*.md) to jpg with white background.
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
#!/usr/bin/env ruby | |
def convert_mermaid_md_to_jpg | |
Dir["mermaid-*.md"].each do |f| | |
slug = f["mermaid-".length...f.length-".md".length] | |
command = "~/node_modules/.bin/mmdc -i mermaid-#{slug}.md -o mermaid-#{slug}.png -b '#FFFFFF'" | |
puts "Converting mermaid-#{slug}.md to mermaid-#{slug}.png" | |
`#{command}` | |
end | |
end | |
if __FILE__ == $0 | |
puts "Converts files matching mermaid-*.md to mermaid-*.png" | |
puts "If this fails you might need to run:" | |
puts "cd ~ && npm install mermaid.cli && popd" | |
convert_mermaid_md_to_jpg | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment