class Octopress::Tags::ImageCaptionTag::Tag
Public Class Methods
new(tag_name, markup, tokens)
click to toggle source
Calls superclass method
# File lib/octopress-image-caption-tag.rb, line 84 def initialize(tag_name, markup, tokens) if %r{(?<classname>\S.*\s+)?(?<protocol>https?://|/)(?<url>\S+)(?<sizes>\s+\d+(\.\d+)?%?(em)?\s+\d+(\.\d+)?%?(em)?)?(?<title>\s+.+)?} =~ markup @class = classname || 'center' @img = "#{protocol}#{url}" @title = title.strip if title parse_sizes(sizes) parse_title(@title) end super end
Public Instance Methods
render(context)
click to toggle source
Calls superclass method
# File lib/octopress-image-caption-tag.rb, line 95 def render(context) super @caption = @title if @img && @width[-1] == '%' # Relative width, so width goes on outer span relative_sized_figure elsif @img && @width[-2..-1] == 'em' # Absolute size in ems em_sized_figure elsif @img # Absolute width, so width goes on the img tag and text span gets sytle-width:@width-15; absolute_sized_figure else 'Error processing input, expected syntax: {% imgcap [class name(s)] /url/to/image [width height] [title [alt]] %}' end end