removed use of content_type strings in the highlighting tag
This commit is contained in:
parent
315f4c9222
commit
84b26a31da
|
@ -26,10 +26,16 @@ module Jekyll
|
|||
@priority || :normal
|
||||
end
|
||||
|
||||
# priority order of this converter
|
||||
def content_type(content_type = nil)
|
||||
@content_type = content_type if content_type
|
||||
@content_type || self.name.downcase.gsub(/^.*::/, '').gsub(/converter$/, '')
|
||||
# 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
|
||||
|
||||
# Spaceship is priority [higher -> lower]
|
||||
|
@ -41,8 +47,14 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
def content_type
|
||||
self.class.content_type
|
||||
# prefix for highlighting
|
||||
def pygments_prefix
|
||||
self.class.pygments_prefix
|
||||
end
|
||||
|
||||
# suffix for highlighting
|
||||
def pygments_suffix
|
||||
self.class.pygments_suffix
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
module Jekyll
|
||||
class MarkdownConverter < Converter
|
||||
pygments_prefix '\n'
|
||||
pygments_suffix '\n'
|
||||
|
||||
def initialize(config = {})
|
||||
# Set the Markdown interpreter (and Maruku self.config, if necessary)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
module Jekyll
|
||||
class TextileConverter < Converter
|
||||
pygments_prefix '<notextile>'
|
||||
pygments_suffix '</notextile>'
|
||||
|
||||
def initialize(config = {})
|
||||
|
||||
|
|
|
@ -46,14 +46,8 @@ module Jekyll
|
|||
converter.output_ext(self.ext)
|
||||
end
|
||||
|
||||
# Determine which formatting engine to use based on this convertible's
|
||||
# Determine which converter to use based on this convertible's
|
||||
# extension
|
||||
#
|
||||
# Returns one of :textile, :markdown or :unknown
|
||||
def content_type
|
||||
converter.content_type
|
||||
end
|
||||
|
||||
def converter
|
||||
@converter ||= self.site.converters.find { |c| c.matches(self.ext) }
|
||||
end
|
||||
|
@ -67,7 +61,8 @@ module Jekyll
|
|||
info = { :filters => [Jekyll::Filters], :registers => { :site => self.site } }
|
||||
|
||||
# render and transform content (this becomes the final content of the object)
|
||||
payload["content_type"] = self.content_type
|
||||
payload["pygments_prefix"] = converter.pygments_prefix
|
||||
payload["pygments_suffix"] = converter.pygments_suffix
|
||||
self.content = Liquid::Template.parse(self.content).render(payload, info)
|
||||
self.transform
|
||||
|
||||
|
|
|
@ -31,11 +31,9 @@ module Jekyll
|
|||
|
||||
def render_pygments(context, code)
|
||||
output = add_code_tags(Albino.new(code, @lang).to_s(@options), @lang)
|
||||
case context["content_type"]
|
||||
when "markdown" then "\n" + output + "\n"
|
||||
when "textile" then "<notextile>" + output + "</notextile>"
|
||||
else output
|
||||
end
|
||||
output = context["pygments_prefix"] + output if context["pygments_prefix"]
|
||||
output = output + context["pygments_suffix"] if context["pygments_suffix"]
|
||||
output
|
||||
end
|
||||
|
||||
def render_codehighlighter(context, code)
|
||||
|
|
|
@ -2,14 +2,15 @@ require File.dirname(__FILE__) + '/helper'
|
|||
|
||||
class TestTags < Test::Unit::TestCase
|
||||
|
||||
def create_post(content, override = {}, content_type = "markdown")
|
||||
def create_post(content, override = {}, converter_class = Jekyll::MarkdownConverter)
|
||||
stub(Jekyll).configuration do
|
||||
Jekyll::DEFAULTS.merge({'pygments' => true}).merge(override)
|
||||
end
|
||||
site = Site.new(Jekyll.configuration)
|
||||
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
|
||||
payload = {"content_type" => content_type}
|
||||
@converter = site.converters.find { |c| c.content_type == content_type }
|
||||
@converter = site.converters.find { |c| c.class == converter_class }
|
||||
payload = { "pygments_prefix" => @converter.pygments_prefix,
|
||||
"pygments_suffix" => @converter.pygments_suffix }
|
||||
|
||||
@result = Liquid::Template.parse(content).render(payload, info)
|
||||
@result = @converter.convert(@result)
|
||||
|
@ -73,7 +74,7 @@ CONTENT
|
|||
|
||||
context "using Textile" do
|
||||
setup do
|
||||
create_post(@content, {}, "textile")
|
||||
create_post(@content, {}, Jekyll::TextileConverter)
|
||||
end
|
||||
|
||||
# Broken in RedCloth 4.1.9
|
||||
|
|
Loading…
Reference in New Issue