Skip to content

Instantly share code, notes, and snippets.

@drosenstark
Last active May 21, 2018 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drosenstark/21b3d7966cc7a0c3056d0776ff7ab8dd to your computer and use it in GitHub Desktop.
Save drosenstark/21b3d7966cc7a0c3056d0776ff7ab8dd to your computer and use it in GitHub Desktop.
Convert all Mermaid Markdown files (mermaid-*.md) to jpg with white background.
#!/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