summaryrefslogtreecommitdiff
path: root/lib/helpers/RstSemantic.rb
diff options
context:
space:
mode:
authorPaul Iannetta <paul.iannetta@inria.fr>2019-06-10 09:04:12 +0200
committerPaul Iannetta <paul.iannetta@inria.fr>2019-06-10 09:04:12 +0200
commit7c8d5e9040490162d8048eddb25f95bdef2f4c90 (patch)
treef29db36e404b84bdde9a75aee3fc583c1a337946 /lib/helpers/RstSemantic.rb
initial commitHEADmaster
Diffstat (limited to 'lib/helpers/RstSemantic.rb')
-rw-r--r--lib/helpers/RstSemantic.rb18
1 files changed, 18 insertions, 0 deletions
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(/<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