Class: Jekyll::ManTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-beastiepress/man_tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ ManTag

Returns a new instance of ManTag.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/jekyll-beastiepress/man_tag.rb', line 27

def initialize(tag_name, markup, tokens)
  if markup =~ /((\d+)\s+)?([a-zA-Z0-9_.]+)(\s+((?:"|')([^"']+)(?:"|')))?(\s+((?:"|')([^"']+)(?:"|')))?(\s+((?:"|')([^"']+)(?:"|')))?/i
    @section = $2
    @man = $3
    @release = $6
    @link = $9
    @title = $12
    if !@link
      @link = @man
      if @section
        @link += "(#{@section})"
      end
      if @release && @title
        @title += " from #{@release}"
      end
    end
    if !@title
      @title = "man #{@man}"
      if @release
        @title += " from #{@release}"
      end
    end
  end
  super
end

Instance Method Details

#render(context) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/jekyll-beastiepress/man_tag.rb', line 53

def render(context)
  output = super
  if @man
    man =  "<a class='man' href='http://www.freebsd.org/cgi/man.cgi?query=#{@man}&amp;ektion=#{@section}&amp;manpath=#{@release}' title='#{@title}'>#{@link}</a>"
  else
    "Error processing input, expected syntax: {% port category/portname ['link text'] ['title text'] %}"
  end
end