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) ⇒ Object private
-
#convert_header(element, options) ⇒ Object
private
Override that adds Homebrew metadata for the top level header and doesn't escape the text inside subheaders.
- #convert_variable(element, options) ⇒ Object private
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, ) 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) ⇒ 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, ) 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) ⇒ 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, ) [:result] << "\\fI#{escape(element.value)}\\fP" end |