This file is indexed.

/usr/lib/ruby/vendor_ruby/maruku/output/to_markdown.rb is in ruby-maruku 0.7.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 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
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
module MaRuKu::Out::Markdown

  DefaultLineLength = 40

  def to_md(context={})
    children_to_md(context)
  end

  # " andrea censi " => [" andrea ", "censi "]
  def mysplit(c)
    res = c.split.map {|x| x + " " }
    if c[0] == ' ' && res[0]
      res[0] = " " + res[0]
    end
    res
  end

  def to_md_header(context)
    pounds = "#" * @level
    "#{pounds} #{children_to_md(context)} #{pounds}\n\n"
  end

  def to_md_inline_code(context)
    "`#{@raw_code}`"
  end

  def to_md_code(context)
    @raw_code.split("\n").collect { |line| "     " + line}.join("\n") + "\n\n"
  end

  def to_md_quote(context)
    line_length = (context[:line_length] || DefaultLineLength) - 2
    wrap(@children, line_length, context).split(/\n/).collect { |line| "> " + line}.join("\n") + "\n"
  end

  def to_md_hrule(context)
    "* * *\n"
  end

  def to_md_emphasis(context)
    "*#{children_to_md(context)}*"
  end

  def to_md_strong(context)
    "**#{children_to_md(context)}**"
  end

  def to_md_immediate_link(context)
    "<#{@url}>"
  end

  def to_md_email_address(context)
    "<#{@email}>"
  end

  def to_md_entity(context)
    "&#{@entity_name};"
  end

  def to_md_linebreak(context)
    "\n"
  end

  def to_md_paragraph(context)
    line_length = context[:line_length] || DefaultLineLength
    wrap(@children, line_length, context)+"\n"
  end

  def to_md_im_link(context)
    "[#{children_to_md(context)}](#{@url}#{" \"#{@title}\"" if @title})"
  end

  def to_md_link(context)
    "[#{children_to_md(context)}][#{@ref_id}]"
  end

  def to_md_im_image(context)
    "![#{children_to_md(context)}](#{@url}#{" \"#{@title}\"" if @title})"
  end

  def to_md_image(context)
    "![#{children_to_md(context)}][#{@ref_id}]"
  end

  def to_md_ref_definition(context)
    "[#{@ref_id}] #{@url}#{" \"#{@title}\"" if @title}"
  end

  def to_md_abbr_def(context)
    "*[#{self.abbr}]: #{self.text}\n"
  end

  def to_md_ol(context)
    len = (context[:line_length] || DefaultLineLength) - 2
    md = ""
    self.children.each_with_index do |li, i|
      #     s = (w=wrap(li.children, len-2, context)).rstrip.gsub(/^/, '    ')+"\n"
      #     s[0,4] = "#{i+1}.  "[0,4]
      #     puts w.inspect
      s = "#{i+1}. " + wrap(li.children, len-2, context).rstrip + "\n"
      md += s
    end
    md + "\n"
  end

  def to_md_ul(context)
    len = (context[:line_length] || DefaultLineLength) - 2
    md = ""
    self.children.each_with_index do |li, i|
      w = wrap(li.children, len-2, context)
      s = "- " + w
      #     puts "W: "+ w.inspect
      #   s = add_indent(w)
      #     puts "S: " +s.inspect
      #   s[0,1] = "-"
      md += s
    end
    md + "\n"
  end

  def add_indent(s,char="    ")
    t = s.split("\n").map{|x| char+x }.join("\n")
    s << ?\n if t[-1] == ?\n
    s
  end

  # Convert each child to html
  def children_to_md(context)
    array_to_md(@children, context)
  end

  def wrap(array, line_length, context)
    out = ""
    line = ""
    array.each do |c|
      if c.kind_of?(MaRuKu::MDElement) &&  c.node_type == :linebreak
        out << line.strip << "  \n"; line="";
        next
      end

      pieces =
        if c.kind_of? String
          mysplit(c)
        elsif c.kind_of?(MaRuKu::MDElement)
          method = "to_md_#{c.node_type}"
          method = "to_md" unless c.respond_to?(method)
          [c.send(method, context)].flatten
        else
          [c.to_md(context)].flatten
        end

      #     puts "Pieces: #{pieces.inspect}"
      pieces.each do |p|
        if p.size + line.size > line_length
          out << line.strip << "\n";
          line = ""
        end
        line << p
      end
    end
    out << line.strip << "\n" if line.size > 0
    out << ?\n if not out[-1] == ?\n
    out
  end


  def array_to_md(array, context, join_char='')
    e = []
    array.each do |c|
      if c.is_a?(String)
        e << c
      else
        method = c.kind_of?(MaRuKu::MDElement) ?
        "to_md_#{c.node_type}" : "to_md"

        if not c.respond_to?(method)
          #raise "Object does not answer to #{method}: #{c.class} #{c.inspect[0,100]}"
          #       tell_user "Using default for #{c.node_type}"
          method = 'to_md'
        end

        #     puts "#{c.inspect} created with method #{method}"
        h =  c.send(method, context)

        if h.nil?
          raise "Nil md for #{c.inspect} created with method #{method}"
        end

        if h.kind_of?Array
          e = e + h
        else
          e << h
        end
      end
    end
    e.join(join_char)
  end

end

module MaRuKu
  class MDDocument
    alias old_md to_md
    def to_md(context={})
      warn "Maruku#to_md is deprecated and will be removed in a near-future version of Maruku."
      old_md(context)
    end
  end
end