예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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
        )
예제 #4
0
  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
예제 #5
0
  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
예제 #6
0
 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]))
예제 #7
0
파일: Base.py 프로젝트: lwxted/n0ted0wn
 def _format_key(cls, n):
     return Util.f(n)
예제 #8
0
파일: Base.py 프로젝트: lwxted/n0ted0wn
 def _format_key(cls, n):
   return Util.f(n)
예제 #9
0
파일: Base.py 프로젝트: lwxted/n0ted0wn
 def _format_key(self, n):
   self._storage_keys.add(n)
   return Util.f(n)
예제 #10
0
 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]))
예제 #11
0
    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)