Class: Albeano
- Inherits:
-
Object
- Object
- Albeano
- Defined in:
- lib/albeano.rb
Constant Summary collapse
- VERSION =
'1.1.0'
Class Method Summary collapse
Instance Method Summary collapse
-
#generate ⇒ String
(also: #to_s)
Newly generated Albino markup.
-
#initialize(text) ⇒ Albeano
constructor
A new instance of Albeano.
-
#to_markdown(*extensions) ⇒ String
(also: #to_md)
The newly generated markup.
Constructor Details
#initialize(text) ⇒ Albeano
Returns a new instance of Albeano.
10 11 12 13 14 15 16 17 |
# File 'lib/albeano.rb', line 10 def initialize(text) if text.respond_to?(:read) @text = text.read else @text = text end @markdown = nil end |
Class Method Details
.generate(text) ⇒ Object
6 7 8 |
# File 'lib/albeano.rb', line 6 def self.generate(text) new(text).generate end |
Instance Method Details
#generate ⇒ String Also known as: to_s
Returns Newly generated Albino markup.
20 21 22 23 24 |
# File 'lib/albeano.rb', line 20 def generate @text.gsub(/\[code(?:=(.+?))?\]\s*(.+?)\s*\[\/code\]/m) do Albino.colorize($2, $1 || :text) end end |
#to_markdown(*extensions) ⇒ String Also known as: to_md
Returns The newly generated markup.
30 31 32 33 34 35 36 37 38 |
# File 'lib/albeano.rb', line 30 def to_markdown(*extensions) begin require 'rdiscount' rescue LoadError raise "Albeano requires RDiscount to render markdown" end @markdown ||= RDiscount.new(generate).to_html end |