From 7c8d5e9040490162d8048eddb25f95bdef2f4c90 Mon Sep 17 00:00:00 2001 From: Paul Iannetta Date: Mon, 10 Jun 2019 09:04:12 +0200 Subject: initial commit --- lib/helpers/RstSemantic.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/helpers/RstSemantic.rb (limited to 'lib/helpers') diff --git a/lib/helpers/RstSemantic.rb b/lib/helpers/RstSemantic.rb new file mode 100644 index 0000000..ac18f9d --- /dev/null +++ b/lib/helpers/RstSemantic.rb @@ -0,0 +1,18 @@ +require 'nokogiri' + +module RstSemantic + def get_toc(raw) + doc = Nokogiri::HTML(raw) + return doc.css("div.contents").to_s.gsub(/
  • .*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>/, '') + end +end -- cgit v1.2.3-54-g00ecf