     $('ul li span.badge').each (_, badge) ->
         parent = $(badge).parent()
         $(badge).detach().prependTo(parent)
+
+wrap_img = () ->
+    $('img').each (_, img) ->
+        alt = $(img).attr('alt')
+        if alt?.trim().length
+            $(img).wrap($('<div>').addClass('figure'))
+                  .after($('<p>').html($('<em>').html(alt)))
+                  .wrap('<p>')
 
 list_toggle = (it) ->
     parent = $(it).parent()

    correct_badge_position()
    make_recent_date()
    monitor_device_mode()

    $('img').each (_, img) ->
        alt = $(img).attr('alt')
        if alt?.trim().length
            $(img).wrap($('<div>').addClass('figure'))
                  .after($('<p>').html($('<em>').html(alt)))
                  .wrap('<p>')

    $('.tag-sort').click (event) ->
        event.preventDefault()

    $('.list-toggle').click (event) ->
        event.preventDefault()
        list_toggle(this)
        correct_fixed_position_width()

    $('#menu-toggle').click (event) ->
        event.preventDefault()
