Sat Jul 5, 2014
Syntax Highlighting - or Embedded Gists
I was quite excited by the inline syntax highlighting that Hugo provides via the python plugin Pygments. But also wanted to try embedding gists
So here is an example…
<p>def digit_sum(n): s = 0 while n: # while n is ‘truthy’ for an integer that means not 0 s = s + (n % 10) # the sum is the sum + the remainder of dividing the incoming number (n) by 10 157 % 10 = 7 n = n / 10 # n = the integer of n / 10 int(15.7) = 15 return s</p> <p>print digit_sum(157)</p> <p>”’ calling digit_sum(157)</p> <h2 id="loop-s-n-n-10-n-10">loop | s | n | n % 10 | n / 10</h2> <p>0 | 0 | 157 | 7 | 15 1 | 7 | 15 | 5 | 1 2 | 12 | 1 | 1 | 0 3 | 13 | 0 | |<br /> ”’</p>
But then thought perhaps it is better to embed gists than have inline markup in blog posts then folk can fork the code and comment there.
So on embedding a gist as follows (but without syntax highlighting) failed…
<script src="https://gist.github.com/danmux/042fa69bed3791afe658.js"> </script>
Putting it in another block partially worked
<p> <script src="https://gist.github.com/danmux/042fa69bed3791afe658.js"> </script> </p>
I was left with an unclosed script tag.
A git of googling turned up this thread…
and this pull request …
which missed the latest release by a few days…
So I went ahead an built the master head - from my fork (ya know just in case I can help)
and added the script tag in….
And it worked !
So gists it is for me