summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/filters/rbstfilter.rb11
-rw-r--r--lib/helpers/RstSemantic.rb18
-rw-r--r--lib/load_helpers.rb6
3 files changed, 35 insertions, 0 deletions
diff --git a/lib/filters/rbstfilter.rb b/lib/filters/rbstfilter.rb
new file mode 100644
index 0000000..8a415d8
--- /dev/null
+++ b/lib/filters/rbstfilter.rb
@@ -0,0 +1,11 @@
+module RbSTFilter
+ class RbST < Nanoc::Filter
+ identifier :rst
+
+ require 'rbst'
+
+ def run(content, params = {})
+ ::RbST.new(content).to_html
+ end
+ end
+end
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
diff --git a/lib/load_helpers.rb b/lib/load_helpers.rb
new file mode 100644
index 0000000..458fbf4
--- /dev/null
+++ b/lib/load_helpers.rb
@@ -0,0 +1,6 @@
+include Nanoc::Helpers::Blogging
+include Nanoc::Helpers::Tagging
+include Nanoc::Helpers::Rendering
+include Nanoc::Helpers::LinkTo
+
+use_helper RstSemantic