def _render(self, obj, storage, env_storage): from n0ted0wn.Block.Renderer import Renderer block_renderer = Renderer(self.style_cls, storage, env_storage) markups = block_renderer.render(obj.blocks_list) return u"""<div style="color: {0};">{1}</div>""".format( Util.html_attribute(obj.color), markups)
def _render(self, obj, storage, env_storage): if obj.numbered: image_counter = env_storage.get(Environment.CURRENT_IMAGE, \ ImageCounter()) image_counter.advance() figure_counter_span = u""" <div class="image-counter-block"> <span class="counter image-counter">Figure {0}</span> </div>""".format(image_counter) if obj.numbered else '' caption_span = u""" <span class="caption-text">{0}</span>"""\ .format(self._format_key(storage.insert(obj.description))) \ if obj.description else '' caption_div = u""" <div class="caption">{0}{1} </div>""".format(figure_counter_span, caption_span) \ if figure_counter_span or caption_span else '' img_center = u' style="margin: 0 auto;"' if obj.center else '' img_width = u' width="{}"'.format(obj.width) if obj.width else '' return u""" <div class="figure clearfix"> <div class="img clearfix"> <img src="{0}" alt="{1}"{3}{4} /> </div>{2} </div>""".format(obj.image_url, Util.html_attribute(obj.alt_caption), caption_div, img_center, img_width)
def _render(self, obj, storage, env_storage): if obj.numbered: image_counter = env_storage.get(Environment.CURRENT_IMAGE, ImageCounter()) image_counter.advance() figure_counter_span = ( u""" <div class="image-counter-block"> <span class="counter image-counter">Figure {0}</span> </div>""".format( image_counter ) if obj.numbered else "" ) caption_span = ( u""" <span class="caption-text">{0}</span>""".format( self._format_key(storage.insert(obj.description)) ) if obj.description else "" ) caption_div = ( u""" <div class="caption">{0}{1} </div>""".format( figure_counter_span, caption_span ) if figure_counter_span or caption_span else "" ) return u""" <div class="figure clearfix"> <div class="img clearfix"> <img src="{0}" alt="{1}" /> </div>{2} </div>""".format( obj.image_url, Util.html_attribute(obj.alt_caption), caption_div )
def recover(self, s, storage_keys=None): """Attempt to replace any placeholder substring with its original string. If `storage_keys` is specified, it will only look into the specified keys. Args: s: String to recover storage_keys: Specific storage keys to look into (default: {None}) Returns: Recovered string str """ if storage_keys is None: storage_keys = self.__data.keys() for n in storage_keys: key = Util.f(n) if key not in s: continue s = s.replace(key, self.recover(self.__data.pop(n))) return s
def _render(cls, inline, final_process): link = inline.content[0] if not link.startswith('http'): link = 'http://' + link return u'<a href="{0}">{1}</a>'.format( Util.html_attribute(link), final_process(inline.content[1]))
def _format_key(cls, n): return Util.f(n)
def _format_key(self, n): self._storage_keys.add(n) return Util.f(n)
def _render(self, obj, storage, env_storage): from n0ted0wn.Block.Renderer import Renderer block_renderer = Renderer(self.style_cls, storage, env_storage) markups = block_renderer.render(obj.blocks_list) return u"""<div style="color: {0};">{1}</div>""".format(Util.html_attribute(obj.color), markups)