forked from jekyll/jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tomdoc and normalize new extension and converter classes
- Loading branch information
Showing
3 changed files
with
77 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,43 @@ | ||
module Jekyll | ||
|
||
class Converter < Extension | ||
# Public: Get or set the pygments prefix. When an argument is specified, | ||
# the prefix will be set. If no argument is specified, the current prefix | ||
# will be returned. | ||
# | ||
# pygments_prefix - The String prefix (default: nil). | ||
# | ||
# Returns the String prefix. | ||
def self.pygments_prefix(pygments_prefix = nil) | ||
@pygments_prefix = pygments_prefix if pygments_prefix | ||
@pygments_prefix | ||
end | ||
|
||
class << self | ||
# prefix for highlighting | ||
def pygments_prefix(pygments_prefix = nil) | ||
@pygments_prefix = pygments_prefix if pygments_prefix | ||
@pygments_prefix | ||
end | ||
|
||
# suffix for highlighting | ||
def pygments_suffix(pygments_suffix = nil) | ||
@pygments_suffix = pygments_suffix if pygments_suffix | ||
@pygments_suffix | ||
end | ||
# Public: Get or set the pygments suffix. When an argument is specified, | ||
# the suffix will be set. If no argument is specified, the current suffix | ||
# will be returned. | ||
# | ||
# pygments_suffix - The String suffix (default: nil). | ||
# | ||
# Returns the String suffix. | ||
def self.pygments_suffix(pygments_suffix = nil) | ||
@pygments_suffix = pygments_suffix if pygments_suffix | ||
@pygments_suffix | ||
end | ||
|
||
# prefix for highlighting | ||
# Get the pygments prefix. | ||
# | ||
# Returns the String prefix. | ||
def pygments_prefix | ||
self.class.pygments_prefix | ||
end | ||
|
||
# suffix for highlighting | ||
# Get the pygments suffix. | ||
# | ||
# Returns the String suffix. | ||
def pygments_suffix | ||
self.class.pygments_suffix | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,62 @@ | ||
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 | ||
# Install a hook so that subclasses are recorded. This method is only | ||
# ever called by Ruby itself. | ||
# | ||
# base - The Class subclass. | ||
# | ||
# Returns nothing. | ||
def self.inherited(base) | ||
subclasses << base | ||
subclasses.sort! | ||
end | ||
|
||
def all | ||
subclasses | ||
end | ||
# The list of Classes that have been subclassed. | ||
# | ||
# Returns an Array of Class objects. | ||
def self.subclasses | ||
@subclasses ||= [] | ||
end | ||
|
||
# priority order of this converter | ||
def priority(priority = nil) | ||
if priority && PRIORITIES.has_key?(priority) | ||
@priority = priority | ||
end | ||
@priority || :normal | ||
# Get or set the priority of this converter. When called without an | ||
# argument it returns the priority. When an argument is given, it will | ||
# set the priority. | ||
# | ||
# priority - The Symbol priority (default: nil). Valid options are: | ||
# :lowest, :low, :normal, :high, :highest | ||
# | ||
# Returns the Symbol priority. | ||
def self.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 | ||
# Spaceship is priority [higher -> lower] | ||
# | ||
# other - The class to be compared. | ||
# | ||
# Returns -1, 0, 1. | ||
def self.<=>(other) | ||
PRIORITIES[other.priority] <=> PRIORITIES[self.priority] | ||
end | ||
|
||
# Initialize a new extension. This should be overridden by the subclass. | ||
# | ||
# config - The Hash of configuration options. | ||
# | ||
# Returns a new instance. | ||
def initialize(config = {}) | ||
#no-op for default | ||
# no-op for default | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters