Class: Homebrew::Manpages::Parser::Ronn Private

Inherits:
Kramdown::Parser::Kramdown
  • Object
show all
Defined in:
manpages/parser/ronn.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.

Kramdown parser with compatiblity for ronn variable syntax.

Constant Summary collapse

VARIABLE_REGEX =

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

HTML-like tags denote variables instead, except
.

/<([\w\-\|]+)>/

Instance Method Summary collapse

Constructor Details

#initializeRonn

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.

Returns a new instance of Ronn.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'manpages/parser/ronn.rb', line 11

def initialize(*)
  super
  # Disable HTML parsing and replace it with variable parsing.
  # Also disable table parsing too because it depends on HTML parsing
  # and existing command descriptions may get misinterpreted as tables.
  # Typographic symbols is disabled as it detects `--` as en-dash.
  @block_parsers.delete(:block_html)
  @block_parsers.delete(:table)
  @span_parsers.delete(:span_html)
  @span_parsers.delete(:typographic_syms)
  @span_parsers << :variable
end

Instance Method Details

#parse_variableObject

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.



26
27
28
29
30
31
32
33
34
35
36
# File 'manpages/parser/ronn.rb', line 26

def parse_variable
  start_line_number = @src.current_line_number
  @src.scan(VARIABLE_REGEX)
  variable = @src[1]
  if variable == "br"
    @src.skip(/\n/)
    @tree.children << Element.new(:br, nil, nil, location: start_line_number)
  else
    @tree.children << Element.new(:variable, variable, nil, location: start_line_number)
  end
end