Class: Homebrew::Manpages::Converter::Roff Private
- Inherits:
-
Kramdown::Converter::Man
- Object
- Kramdown::Converter::Man
- Homebrew::Manpages::Converter::Roff
- 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
- #convert_a(element, options) ⇒ void private
-
#convert_header(element, options) ⇒ void
private
Override that adds Homebrew metadata for the top level header and doesn't escape the text inside subheaders.
- #convert_variable(element, options) ⇒ void private
Instance Method Details
#convert_a(element, options) ⇒ void
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.
This method returns an undefined value.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'manpages/converter/roff.rb', line 38 def convert_a(element, ) if element.attr["href"].chr == "#" # Hide internal links - just make them italicised convert_em(element, ) else super # Remove the space after links if the next character is not a space if [:result].end_with?(".UE\n") && (next_element = [:next]) && next_element.type == :text && next_element.value.chr.present? # i.e. not a space character [:result].chomp! [:result] << " " end end end |
#convert_header(element, options) ⇒ void
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.
This method returns an undefined value.
Override that adds Homebrew metadata for the top level header and doesn't escape the text inside subheaders.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'manpages/converter/roff.rb', line 14 def convert_header(element, ) if element.[:level] == 1 element.attr["data-date"] = Date.today.strftime("%B %Y") element.attr["data-extra"] = "Homebrew" return super end result = +"" inner(element, .merge(result:)) result.gsub!(" [", ' \fR[') # make args not bold [:result] << if element.[:level] == 2 macro("SH", quote(result)) else macro("SS", quote(result)) end end |
#convert_variable(element, options) ⇒ void
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.
This method returns an undefined value.
33 34 35 |
# File 'manpages/converter/roff.rb', line 33 def convert_variable(element, ) [:result] << "\\fI#{escape(element.value)}\\fP" end |