code: def rewrite_url(self, url, is_image_src=False):
          
          rewrite = self.img_src_rewrite if is_image_src else self.link_rewrite
          if rewrite:
              return rewrite.format(url=urlquote(url))
          return url
docs: This method is called to rewrite URLs.
  
          It uses either ``self.link_rewrite`` or ``self.img_src_rewrite``
          depending on the value of ``is_image_src``. The URL is returned
          unchanged if the corresponding attribute is :obj:`None`.