Class: Jekyll::ImgConverter

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/jekyll-img-converter.rb

Instance Method Summary collapse

Instance Method Details

#image(link, title, content) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jekyll-img-converter.rb', line 8

def image(link, title, content)
  # content &&= content
  pattern = /({)(.+)(})/
  matchData = pattern.match(content)
  
  imgTag = "<img src=\"#{link}\""
  
  if (matchData)
    style = matchData[0]
    stripContent = content.gsub(style,'')
    imgTag += " alt=\"#{stripContent}\" style=\"#{style}\""
  else
    imgTag += " alt=\"#{content}\""
  end

  if(title)
    imgTag += " title=\"#{title}\""
  end

  imgTag = imgTag + "/>"
end