Sha256: e5c765f19456814f3e05ba857f695ad48286f647540bd930dc78b837c64f6d80
Contents?: true
Size: 819 Bytes
Versions: 1
Compression:
Stored size: 819 Bytes
Contents
require 'nokogiri' module Govspeak class PostProcessor attr_reader :input @@extensions = [] def initialize(html) @input = html end def nokogiri_document doc = Nokogiri::HTML::Document.new doc.encoding = "UTF-8" doc.fragment(input) end private :nokogiri_document def self.process(html) new(html).output end def self.extension(title, &block) @@extensions << [title, block] end def output document = nokogiri_document @@extensions.each do |_, block| instance_exec(document, &block) end document.to_html end extension("add class to last p of blockquote") do |document| document.css("blockquote p:last-child").map do |el| el[:class] = "last-child" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
govspeak-4.0.0 | lib/govspeak/post_processor.rb |