<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>hriki/preprocess/basic_clean.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -71,14 +71,17 @@ module Hriki
 #           Config.numbacklinks = b
 #         end
         
-         opts.on(&quot;--srcdir SRCDIR&quot;, &quot;The directory to draw from!&quot;) do |s|
-           Config.srcdir = s
-         end
-
-         opts.on(&quot;--destdir DESTDIR&quot;, &quot;The destination!&quot;) do |d|
-           Config.destdir = d
-         end
-
+        opts.on(&quot;--srcdir SRCDIR&quot;, &quot;The directory to draw from!&quot;) do |s|
+          Config.srcdir = s
+        end
+        
+        opts.on(&quot;--destdir DESTDIR&quot;, &quot;The destination!&quot;) do |d|
+          Config.destdir = d
+        end
+        
+        opts.on(&quot;--preprocdir PROCDIR&quot;, &quot;Where plugins are held&quot;) do |d|
+          Config.preprocdir = d
+        end
 #         opts.on(&quot;--rcs RCS&quot;, [:git, :svn, :hg], &quot;Set the RCS type to pull the wiki from&quot;) do |r|
 #           Config.rcs = r
 #         end
@@ -147,9 +150,9 @@ module Hriki
 #           Config.underlaydir = u
 #         end
 
-#         opts.on(&quot;--plugin x,y,z&quot;, Array, &quot;List of plugins to use&quot;) do |p|
-#           Config.plugin = p
-#         end
+         opts.on(&quot;--plugin x,y,z&quot;, Array, &quot;List of plugins to use&quot;) do |p|
+           Config.plugin = p
+         end
 
 #         opts.on(&quot;--disable-plugin x,y,z&quot;, Array, &quot;List of plugns to not use&quot;) do |d|
 #           Config.disable_plugin = d
@@ -178,10 +181,11 @@ module Hriki
 
   def self.run
     Opts.parse(ARGV)
-    Config.srcdir = &quot;~/code/test/hriki/src&quot;
-    Config.destdir = &quot;~/code/test/hriki/dest&quot;
+    Config.srcdir = &quot;~/code/hriki/test/src&quot;
+    Config.destdir = &quot;~/code/hriki/test/dest&quot;
     Config.htmlext = &quot;.html&quot;
     Config.srcext = &quot;.mdwn&quot;
+    Config.plugin = ['basic_clean']
     puts &quot;Oh, this wont go well...&quot;
     Render.all
   end</diff>
      <filename>hriki.rb</filename>
    </modified>
    <modified>
      <diff>@@ -80,6 +80,8 @@ module Hriki #:nodoc:
     @@destdir = &quot;~/www&quot;
     @@htmlext = &quot;.html&quot;
     @@srcext = &quot;.mdwn&quot;
+    @@preprocdir = &quot;~/code/hriki/hriki/preprocess&quot;
+    @@plugin = ['basic_clean']
     
     # give them some getters and setters!
     class_variables.each { |v| mattr_accessor v[(2..-1)] }</diff>
      <filename>hriki/config.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,8 +12,8 @@ module Hriki
                                                      Config.destdir,
                                                      File.basename(path, Config.srcext)
                                                      ) + Config.htmlext), &quot;w&quot;)
-      preproc = Preprocess.new(File.read(path))
-      mdwnsrc = Maruku.new(preproc).to_html
+      preproc = PreProcess.run_plugins(File.read(path))
+      mdwnsrc = Maruku.new(preproc.to_s).to_html
       hengine = Haml::Engine.new(mdwnsrc)
       @destfile.write(hengine.to_html)
     end</diff>
      <filename>hriki/page.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,48 @@
+require 'hriki/config'
+
 module Hriki
-  class PreProcess
-    attr_accessor :src
-    def initialize str
-      @src = str
+  module PreProcess
+    module PluginSugar
+      def def_field(*names)
+        class_eval do 
+          names.each do |name|
+            define_method(name) do |*args| 
+              case args.size
+              when 0: instance_variable_get(&quot;@#{name}&quot;)
+              else    instance_variable_set(&quot;@#{name}&quot;, *args)
+              end
+            end
+          end
+        end
+      end
+    end
+    
+    class Plugin
+      @registered_plugins = {}
+
+      class &lt;&lt; self
+        attr_reader :registered_plugins
+        private :new
+      end
+      
+      def self.define(name, &amp;block)
+        p = new
+        p.instance_eval(&amp;block)
+        Plugin.registered_plugins[name] = p
+      end
+
+      extend PluginSugar
+      def_field :author, :version, :url
+    end
+    
+    def self.load_plugins
+      Dir[&quot;#{Config.preprocdir}/*.rb&quot;].each { |p| load p }
+    end
+
+    def self.run_plugins(str)
+      Plugin.registered_plugins.each { |k, p|
+        str = p.process(str) if Config.plugin.include(k)
+      }
     end
   end
 end</diff>
      <filename>hriki/preprocess.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@
 require 'find'
 require 'hriki/page'
 require 'hriki/config'
+require 'hriki/preprocess'
 
 module Hriki
   class Render
@@ -12,6 +13,7 @@ module Hriki
     # plug markdown into haml
     # markdown.to_html
     def self.all
+      PreProcess.load_plugins
       Find.find(File.expand_path(Config.srcdir)) do |path|
         if File.extname(path).downcase != Config.srcext
           puts &quot;Skipping incorrect extenion: #{path}&quot;</diff>
      <filename>hriki/render.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>hriki/.#preprocess.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>716f3e98d2b7e05362a7323833f78b9ff21ce7c2</id>
    </parent>
  </parents>
  <author>
    <name>Jeff Mickey</name>
    <email>jeff@archlinux.org</email>
  </author>
  <url>http://github.com/codemac/hriki/commit/dc26cc70d54cee167c83a3ccecb21298cc64728b</url>
  <id>dc26cc70d54cee167c83a3ccecb21298cc64728b</id>
  <committed-date>2008-06-13T15:37:28-07:00</committed-date>
  <authored-date>2008-06-13T15:37:28-07:00</authored-date>
  <message>This surely doesn't work yet, but I'm getting somewhere.

Signed-off-by: Jeff Mickey &lt;jeff@archlinux.org&gt;</message>
  <tree>51eb618905f582127b473a726e5fac6fa2d86981</tree>
  <committer>
    <name>Jeff Mickey</name>
    <email>jeff@archlinux.org</email>
  </committer>
</commit>
