Recent Posts

Full Category Index

Posts in “Gists”

Embedded Gists

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>

<p>print digit_sum(157)</p>

<p>”’
calling digit_sum(157)</p>

<h2>loop  | s   | n   | n % 10  | n / 10</h2>

<p><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…