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/filters/rbstfilter.rb | 11 +++++++++++ lib/helpers/RstSemantic.rb | 18 ++++++++++++++++++ lib/load_helpers.rb | 6 ++++++ 3 files changed, 35 insertions(+) create mode 100644 lib/filters/rbstfilter.rb create mode 100644 lib/helpers/RstSemantic.rb create mode 100644 lib/load_helpers.rb (limited to 'lib') 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(/
  • .*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 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 -- cgit v1.2.3-54-g00ecf