Module: Jekyll::Converters::Markdown::RedcarpetParser::CommonMethods

Defined in:
lib/jekyll-img-converter.rb

Instance Method Summary collapse

Instance Method Details

#image(link, title, content) ⇒ Object

def postprocess(full_document)

Regexp.new(/\A<p>(.*)<\/p>\Z/m).match(full_document)[1] rescue full_document

end def postprocess(document)

document.gsub("\n", '').strip

end



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jekyll-img-converter.rb', line 16

def image(link, title, content)
  pattern = /({)(.+)(})/
  matchData = pattern.match(content)

  imgTag = "<img src=\"#{link}\""

  if (matchData)        
    style = matchData[2]
    stripContent = content.gsub(matchData.to_s,'').rstrip
  
    imgTag += " alt=\"#{stripContent}\" style=\"#{style}\""
  else
    imgTag += " alt=\"#{content}\""
  end
      
  if(title)
    imgTag += " title=\"#{title}\""
  end
      
  imgTag += "/>"
end