Style: Don't put 'require' statements inside methods
This commit is contained in:
parent
ca1e8de89c
commit
4901279391
3 changed files with 8 additions and 13 deletions
|
@ -2,7 +2,10 @@ $: << File.dirname(__FILE__) + "../../lib"
|
||||||
|
|
||||||
require_dependency 'chunks/chunk'
|
require_dependency 'chunks/chunk'
|
||||||
require 'stringsupport'
|
require 'stringsupport'
|
||||||
|
require 'maruku'
|
||||||
|
require 'maruku/ext/math'
|
||||||
|
require_dependency 'rdocsupport'
|
||||||
|
require 'redcloth'
|
||||||
|
|
||||||
# The markup engines are Chunks that call the one of RedCloth
|
# The markup engines are Chunks that call the one of RedCloth
|
||||||
# or RDoc to convert text. This markup occurs when the chunk is required
|
# or RDoc to convert text. This markup occurs when the chunk is required
|
||||||
|
@ -27,7 +30,6 @@ module Engines
|
||||||
|
|
||||||
class Textile < AbstractEngine
|
class Textile < AbstractEngine
|
||||||
def mask
|
def mask
|
||||||
require 'redcloth'
|
|
||||||
redcloth = RedCloth.new(@content, [:hard_breaks] + @content.options[:engine_opts])
|
redcloth = RedCloth.new(@content, [:hard_breaks] + @content.options[:engine_opts])
|
||||||
redcloth.filter_html = false
|
redcloth.filter_html = false
|
||||||
redcloth.no_span_caps = false
|
redcloth.no_span_caps = false
|
||||||
|
@ -37,9 +39,6 @@ module Engines
|
||||||
|
|
||||||
class Markdown < AbstractEngine
|
class Markdown < AbstractEngine
|
||||||
def mask
|
def mask
|
||||||
require 'maruku'
|
|
||||||
require 'maruku/ext/math'
|
|
||||||
|
|
||||||
# If the request is for S5, call Maruku accordingly (without math)
|
# If the request is for S5, call Maruku accordingly (without math)
|
||||||
if @content.options[:mode] == :s5
|
if @content.options[:mode] == :s5
|
||||||
my_content = Maruku.new(@content.delete("\r").to_utf8,
|
my_content = Maruku.new(@content.delete("\r").to_utf8,
|
||||||
|
@ -57,9 +56,6 @@ module Engines
|
||||||
|
|
||||||
class MarkdownMML < AbstractEngine
|
class MarkdownMML < AbstractEngine
|
||||||
def mask
|
def mask
|
||||||
require 'maruku'
|
|
||||||
require 'maruku/ext/math'
|
|
||||||
|
|
||||||
# If the request is for S5, call Maruku accordingly
|
# If the request is for S5, call Maruku accordingly
|
||||||
if @content.options[:mode] == :s5
|
if @content.options[:mode] == :s5
|
||||||
my_content = Maruku.new(@content.delete("\r").to_utf8,
|
my_content = Maruku.new(@content.delete("\r").to_utf8,
|
||||||
|
@ -81,7 +77,6 @@ module Engines
|
||||||
|
|
||||||
class Mixed < AbstractEngine
|
class Mixed < AbstractEngine
|
||||||
def mask
|
def mask
|
||||||
require 'redcloth'
|
|
||||||
redcloth = RedCloth.new(@content, @content.options[:engine_opts])
|
redcloth = RedCloth.new(@content, @content.options[:engine_opts])
|
||||||
redcloth.filter_html = false
|
redcloth.filter_html = false
|
||||||
redcloth.no_span_caps = false
|
redcloth.no_span_caps = false
|
||||||
|
@ -91,11 +86,10 @@ module Engines
|
||||||
|
|
||||||
class RDoc < AbstractEngine
|
class RDoc < AbstractEngine
|
||||||
def mask
|
def mask
|
||||||
require_dependency 'rdocsupport'
|
|
||||||
html = RDocSupport::RDocFormatter.new(@content).to_html
|
html = RDocSupport::RDocFormatter.new(@content).to_html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
MAP = { :textile => Textile, :markdown => Markdown, :markdownMML => MarkdownMML, :mixed => Mixed, :rdoc => RDoc }
|
MAP = { :textile => Textile, :markdown => Markdown, :markdownMML => MarkdownMML, :mixed => Mixed, :rdoc => RDoc }
|
||||||
MAP.default = Textile
|
MAP.default = MarkdownMML
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'chunks/chunk'
|
require 'chunks/chunk'
|
||||||
|
require 'sanitize'
|
||||||
|
|
||||||
# This chunks allows certain parts of a wiki page to be hidden from the
|
# This chunks allows certain parts of a wiki page to be hidden from the
|
||||||
# rest of the rendering pipeline. It should be run at the beginning
|
# rest of the rendering pipeline. It should be run at the beginning
|
||||||
|
@ -16,7 +17,6 @@ require 'chunks/chunk'
|
||||||
|
|
||||||
class NoWiki < Chunk::Abstract
|
class NoWiki < Chunk::Abstract
|
||||||
|
|
||||||
require 'sanitize'
|
|
||||||
include Sanitize
|
include Sanitize
|
||||||
|
|
||||||
NOWIKI_PATTERN = Regexp.new('<nowiki>(.*?)</nowiki>', Regexp::MULTILINE)
|
NOWIKI_PATTERN = Regexp.new('<nowiki>(.*?)</nowiki>', Regexp::MULTILINE)
|
||||||
|
|
|
@ -5,6 +5,8 @@ require_dependency 'chunks/include'
|
||||||
require_dependency 'chunks/wiki'
|
require_dependency 'chunks/wiki'
|
||||||
require_dependency 'chunks/literal'
|
require_dependency 'chunks/literal'
|
||||||
require 'chunks/nowiki'
|
require 'chunks/nowiki'
|
||||||
|
require 'sanitizer'
|
||||||
|
|
||||||
|
|
||||||
# Wiki content is just a string that can process itself with a chain of
|
# Wiki content is just a string that can process itself with a chain of
|
||||||
# actions. The actions can modify wiki content so that certain parts of
|
# actions. The actions can modify wiki content so that certain parts of
|
||||||
|
@ -112,7 +114,6 @@ end
|
||||||
|
|
||||||
class WikiContent < String
|
class WikiContent < String
|
||||||
|
|
||||||
require 'sanitizer'
|
|
||||||
include ChunkManager
|
include ChunkManager
|
||||||
include Sanitizer
|
include Sanitizer
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue