#NEWLINE# def test_custom_renderer( self , html ) : #NEWLINE# #INDENT# class CustomRenderer ( misaka . HtmlRenderer ) : #NEWLINE# #INDENT# def image( self , link , title , alt_text ) : #NEWLINE# #INDENT# return '<div><img src="{0}" alt="{2}" title="{1}"><div>{1}</div></div>' . format ( link , title , alt_text ) #NEWLINE# #UNINDENT# #UNINDENT# test_md = '![Alt text](/img.jpg "Title")' #NEWLINE# expected_result = '<p><div><img src="/img.jpg" alt="Alt text" title="Title"><div>Title</div></div></p>\n' #NEWLINE# md = Misaka ( None , CustomRenderer ( ) ) #NEWLINE# result = md . render ( html ) #NEWLINE# self . assertFalse ( html . called ) #NEWLINE# self . assertEqual ( str ( result ) , expected_result )