summaryrefslogtreecommitdiff
path: root/lib/helpers/RstSemantic.rb
blob: ac18f9ddb894242fb8c38ff6a52573b74279a41c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'nokogiri'

module RstSemantic
  def get_toc(raw)
    doc = Nokogiri::HTML(raw)
    return doc.css("div.contents").to_s.gsub(/<li>.*Summary<\/a><\/li>/, '')
  end

  def get_content(raw)
    doc = Nokogiri::HTML(raw)
    return doc.css("div.document > div.section")[1..-1]
  end

  def get_summary(raw)
    doc = Nokogiri::HTML(raw)
    return doc.css("div.section").first.to_s.gsub(/<h1>.*<\/h1>/, '')
  end
end