Module: Octopress::CodeHighlighter
- Defined in:
- lib/octopress-code-highlighter.rb,
lib/octopress-code-highlighter/cache.rb,
lib/octopress-code-highlighter/version.rb,
lib/octopress-code-highlighter/renderer.rb,
lib/octopress-code-highlighter/options_parser.rb
Defined Under Namespace
Classes: Cache, OptionsParser, Renderer
Constant Summary
collapse
- DEFAULTS =
{
lang: 'plain',
linenos: true,
marks: [],
start: 1
}
- VERSION =
"3.0.0"
Class Method Summary
collapse
Class Method Details
.clean_markup(input) ⇒ Object
36
37
38
|
# File 'lib/octopress-code-highlighter.rb', line 36
def self.clean_markup(input)
OptionsParser.new(input).clean_markup
end
|
.highlight(code, options = {}) ⇒ Object
24
25
26
|
# File 'lib/octopress-code-highlighter.rb', line 24
def self.highlight(code, options={})
Renderer.new(code, options).highlight
end
|
.highlight_failed(error, syntax, markup, code, file = nil) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/octopress-code-highlighter.rb', line 40
def self.highlight_failed(error, syntax, markup, code, file = nil)
code_snippet = code.split("\n")[0..9].map{|l| " #{l}" }.join("\n")
fail_message = "\nError while parsing the following markup#{" in #{file}" if file}:\n\n".red
fail_message += " #{markup}\n#{code_snippet}\n"
fail_message += "#{" ..." if code.split("\n").size > 10}\n"
fail_message += "\nValid Syntax:\n\n#{syntax}\n".yellow
fail_message += "\nError:\n\n#{error.message}".red
$stderr.puts fail_message.chomp
raise ArgumentError
end
|
.parse_markup(input, defaults = {}) ⇒ Object
32
33
34
|
# File 'lib/octopress-code-highlighter.rb', line 32
def self.parse_markup(input, defaults={})
OptionsParser.new(input).parse_markup(defaults)
end
|
.read_cache(code, options = {}) ⇒ Object
28
29
30
|
# File 'lib/octopress-code-highlighter.rb', line 28
def self.read_cache(code, options={})
Cache.read_cache(code, options)
end
|