Class: Homebrew::Manpages::Converter::Roff Private

Inherits:
Kramdown::Converter::Man
  • Object
show all
Defined in:
manpages/converter/roff.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Converts our Kramdown-like input to roff.

Instance Method Summary collapse

Instance Method Details

#convert_a(element, options) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'manpages/converter/roff.rb', line 35

def convert_a(element, options)
  if element.attr["href"].chr == "#"
    # Hide internal links - just make them italicised
    convert_em(element, options)
  else
    super
    # Remove the space after links if the next character is not a space
    if options[:result].end_with?(".UE\n") &&
       (next_element = options[:next]) &&
       next_element.type == :text &&
       next_element.value.chr.present? # i.e. not a space character
      options[:result].chomp!
      options[:result] << " "
    end
  end
end

#convert_header(element, options) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Override that adds Homebrew metadata for the top level header and doesn't escape the text inside subheaders.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'manpages/converter/roff.rb', line 13

def convert_header(element, options)
  if element.options[:level] == 1
    element.attr["data-date"] = Date.today.strftime("%B %Y")
    element.attr["data-extra"] = "Homebrew"
    return super
  end

  result = +""
  inner(element, options.merge(result:))
  result.gsub!(" [", ' \fR[') # make args not bold

  options[:result] << if element.options[:level] == 2
    macro("SH", quote(result))
  else
    macro("SS", quote(result))
  end
end

#convert_variable(element, options) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



31
32
33
# File 'manpages/converter/roff.rb', line 31

def convert_variable(element, options)
  options[:result] << "\\fI#{escape(element.value)}\\fP"
end