From e97e4769e1e43fa27193596e968d529537c94f6c Mon Sep 17 00:00:00 2001
From: Dmitry Shachnev <mitya57@gmail.com>
Date: Thu, 22 Dec 2016 11:06:39 +0300
Subject: [PATCH] Make rest2html work with docutils 0.13

In that docutils version, HTMLTranslator.visit_image no longer appends
empty string to self.context, so trying to pop() from there raises an
IndexError.

Instead of the hard-coded pop call, call the overridden method, which will
call pop() on docutils 0.12 and will do nothing on docutils 0.13.

Fixes #971.

Also, fix the comment indentation.
---
 lib/github/commands/rest2html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/lib/github/commands/rest2html
+++ b/lib/github/commands/rest2html
@@ -142,9 +142,9 @@
 
             # toss off `object` tag
             self.body.pop()
-        # add on `img` with attributes
+            # add on `img` with attributes
             self.body.append(self.starttag(node, 'img', **atts))
-        self.body.append(self.context.pop())
+        HTMLTranslator.depart_image(self, node)
 
 
 def kbd(name, rawtext, text, lineno, inliner, options=None, content=None):
