extended concept to extensions in general, providing both converters and generators
This commit is contained in:
parent
84b26a31da
commit
fc86c9dd85
|
@ -27,10 +27,17 @@ require 'jekyll/tags/highlight'
|
||||||
require 'jekyll/tags/include'
|
require 'jekyll/tags/include'
|
||||||
require 'jekyll/albino'
|
require 'jekyll/albino'
|
||||||
require 'jekyll/static_file'
|
require 'jekyll/static_file'
|
||||||
|
|
||||||
|
#extensions
|
||||||
|
require 'jekyll/extension'
|
||||||
require 'jekyll/converter'
|
require 'jekyll/converter'
|
||||||
require 'jekyll/converters/identity'
|
Dir["#{File.dirname(__FILE__)}/jekyll/converters/*.rb"].each do |file|
|
||||||
require 'jekyll/converters/markdown'
|
require file
|
||||||
require 'jekyll/converters/textile'
|
end
|
||||||
|
require 'jekyll/generator'
|
||||||
|
Dir["#{File.dirname(__FILE__)}/jekyll/generators/*.rb"].each do |file|
|
||||||
|
require file
|
||||||
|
end
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
# Default options. Overriden by values in _config.yml or command-line opts.
|
# Default options. Overriden by values in _config.yml or command-line opts.
|
||||||
|
|
|
@ -1,31 +1,8 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class Converter
|
class Converter < Extension
|
||||||
|
|
||||||
PRIORITIES = { :lowest => -100,
|
|
||||||
:low => -10,
|
|
||||||
:normal => 0,
|
|
||||||
:high => 10,
|
|
||||||
:highest => 100 }
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def subclasses
|
|
||||||
@subclasses ||= []
|
|
||||||
end
|
|
||||||
|
|
||||||
def inherited(base)
|
|
||||||
subclasses << base
|
|
||||||
subclasses.sort!
|
|
||||||
end
|
|
||||||
|
|
||||||
# priority order of this converter
|
|
||||||
def priority(priority = nil)
|
|
||||||
if priority && PRIORITIES.has_key?(priority)
|
|
||||||
@priority = priority
|
|
||||||
end
|
|
||||||
@priority || :normal
|
|
||||||
end
|
|
||||||
|
|
||||||
# prefix for highlighting
|
# prefix for highlighting
|
||||||
def pygments_prefix(pygments_prefix = nil)
|
def pygments_prefix(pygments_prefix = nil)
|
||||||
@pygments_prefix = pygments_prefix if pygments_prefix
|
@pygments_prefix = pygments_prefix if pygments_prefix
|
||||||
|
@ -37,14 +14,6 @@ module Jekyll
|
||||||
@pygments_suffix = pygments_suffix if pygments_suffix
|
@pygments_suffix = pygments_suffix if pygments_suffix
|
||||||
@pygments_suffix
|
@pygments_suffix
|
||||||
end
|
end
|
||||||
|
|
||||||
# Spaceship is priority [higher -> lower]
|
|
||||||
#
|
|
||||||
# Returns -1, 0, 1
|
|
||||||
def <=>(other)
|
|
||||||
cmp = PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
|
|
||||||
return cmp
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# prefix for highlighting
|
# prefix for highlighting
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class IdentityConverter < Converter
|
class IdentityConverter < Converter
|
||||||
priority :lowest
|
priority :lowest
|
||||||
|
|
||||||
def initialize(config = {})
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def matches(ext)
|
def matches(ext)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -19,4 +16,5 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class MarkdownConverter < Converter
|
class MarkdownConverter < Converter
|
||||||
pygments_prefix '\n'
|
pygments_prefix '\n'
|
||||||
pygments_suffix '\n'
|
pygments_suffix '\n'
|
||||||
|
@ -62,4 +63,5 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class TextileConverter < Converter
|
class TextileConverter < Converter
|
||||||
pygments_prefix '<notextile>'
|
pygments_prefix '<notextile>'
|
||||||
pygments_suffix '</notextile>'
|
pygments_suffix '</notextile>'
|
||||||
|
|
||||||
def initialize(config = {})
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def matches(ext)
|
def matches(ext)
|
||||||
ext =~ /textile/i
|
ext =~ /textile/i
|
||||||
end
|
end
|
||||||
|
@ -20,4 +17,5 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
module Jekyll
|
||||||
|
|
||||||
|
class Extension
|
||||||
|
|
||||||
|
PRIORITIES = { :lowest => -100,
|
||||||
|
:low => -10,
|
||||||
|
:normal => 0,
|
||||||
|
:high => 10,
|
||||||
|
:highest => 100 }
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def subclasses
|
||||||
|
@subclasses ||= []
|
||||||
|
end
|
||||||
|
|
||||||
|
def inherited(base)
|
||||||
|
subclasses << base
|
||||||
|
subclasses.sort!
|
||||||
|
end
|
||||||
|
|
||||||
|
# priority order of this converter
|
||||||
|
def priority(priority = nil)
|
||||||
|
if priority && PRIORITIES.has_key?(priority)
|
||||||
|
@priority = priority
|
||||||
|
end
|
||||||
|
@priority || :normal
|
||||||
|
end
|
||||||
|
|
||||||
|
# Spaceship is priority [higher -> lower]
|
||||||
|
#
|
||||||
|
# Returns -1, 0, 1
|
||||||
|
def <=>(other)
|
||||||
|
cmp = PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
|
||||||
|
return cmp
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(config = {})
|
||||||
|
#no-op for default
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
module Jekyll
|
||||||
|
|
||||||
|
class Generator < Extension
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
module Jekyll
|
||||||
|
|
||||||
|
class Pagination < Generator
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -3,7 +3,8 @@ module Jekyll
|
||||||
class Site
|
class Site
|
||||||
attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude,
|
attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude,
|
||||||
:source, :dest, :lsi, :pygments, :permalink_style, :tags, :time,
|
:source, :dest, :lsi, :pygments, :permalink_style, :tags, :time,
|
||||||
:future, :converters
|
:future
|
||||||
|
attr_accessor :converters, :generators
|
||||||
|
|
||||||
# Initialize the site
|
# Initialize the site
|
||||||
# +config+ is a Hash containing site configurations details
|
# +config+ is a Hash containing site configurations details
|
||||||
|
@ -39,6 +40,7 @@ module Jekyll
|
||||||
require 'classifier' if self.lsi
|
require 'classifier' if self.lsi
|
||||||
|
|
||||||
self.converters = Jekyll::Converter.subclasses.collect { |c| c.new(self.config) }
|
self.converters = Jekyll::Converter.subclasses.collect { |c| c.new(self.config) }
|
||||||
|
self.generators = Jekyll::Generator.subclasses.collect { |c| c.new(self.config) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Do the actual work of processing the site and generating the
|
# Do the actual work of processing the site and generating the
|
||||||
|
|
Loading…
Reference in New Issue