Class: Markabb::SyntaxHighlighter
- Inherits:
-
Object
- Object
- Markabb::SyntaxHighlighter
- Defined in:
- lib/markabb/classes/syntax_highlighter.rb
Overview
Super class for syntax highlighters
All syntax highlighters need to inherit from this class
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(config) ⇒ SyntaxHighlighter
constructor
A new instance of SyntaxHighlighter.
-
#run(s) ⇒ Object
Runs the syntax highlighter.
Constructor Details
#initialize(config) ⇒ SyntaxHighlighter
Returns a new instance of SyntaxHighlighter.
19 20 21 |
# File 'lib/markabb/classes/syntax_highlighter.rb', line 19 def initialize(config) @config = config end |
Instance Method Details
#run(s) ⇒ Object
Runs the syntax highlighter
Finds all instances of the code tag and passes it to the parse function
26 27 28 29 30 31 32 |
# File 'lib/markabb/classes/syntax_highlighter.rb', line 26 def run(s) out = s out.scan(/\[code lang=(.+?)\](.+?)\[\/code\]/m).each do |lang, parse| out = out.gsub("[code lang=#{lang}]#{parse}[/code]", parse(lang, parse)) end return out end |