Skip to content

Commit

Permalink
Allow various sizes for the dot/graphviz stuff, and include google an…
Browse files Browse the repository at this point in the history
…alytics
  • Loading branch information
plexus committed Jun 25, 2013
1 parent 324243d commit 2acb0ab
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/impress_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ def hrule
end

def block_code code, lang
if lang == 'dot'
if lang =~ /^dot/
_, size = lang.split('-')
file = Tempfile.new(['mdpress','.dot'])
file << code
file.close
"<div class='dot-wrap'>" +
(Nokogiri(`dot #{file.path} -Tsvg`)/'svg').first.tap{|svg| svg.search('polygon').first.remove; svg['width']='600px' ; svg.attributes['height'].remove }.to_html +
(Nokogiri(`dot #{file.path} -Tsvg`)/'svg').first.tap{|svg| svg.search('polygon').first.remove; svg['width']=(size||'600')+'px' ; svg.attributes['height'].remove }.to_html +
"</div>"
elsif lang == 'notes'
"<div class='notes' style='display:none;'>#{code}</div>"
Expand Down Expand Up @@ -111,6 +112,17 @@ def doc_header
<link href="css/highlight.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16178122-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
#{mathjax}
<link href="css/style.css" rel="stylesheet" />
#{@head}
Expand Down

0 comments on commit 2acb0ab

Please sign in to comment.