Class: Creole::Parser
- Inherits:
-
Object
- Object
- Creole::Parser
- Defined in:
- lib/creole/parser.rb
Instance Attribute Summary collapse
-
#allowed_schemes ⇒ Object
Allowed url schemes Examples: http https ftp ftps.
-
#extensions ⇒ Object
writeonly
Non-standard wiki text extensions enabled? E.g.
-
#no_escape ⇒ Object
writeonly
Disable url escaping for local links Escaping: [[/Test]] –> %2FTest No escaping: [[/Test]] –> Test.
Instance Method Summary collapse
- #extensions? ⇒ Boolean
-
#initialize(text, options = {}) ⇒ Parser
constructor
Create a new CreoleParser instance.
- #no_escape? ⇒ Boolean
-
#to_html ⇒ Object
Convert CCreole text to HTML and return the result.
Constructor Details
#initialize(text, options = {}) ⇒ Parser
Create a new CreoleParser instance.
57 58 59 60 61 62 |
# File 'lib/creole/parser.rb', line 57 def initialize(text, = {}) @allowed_schemes = %w(http https ftp ftps) @text = text @extensions = @no_escape = nil .each_pair {|k,v| send("#{k}=", v) } end |
Instance Attribute Details
#allowed_schemes ⇒ Object
Allowed url schemes Examples: http https ftp ftps
43 44 45 |
# File 'lib/creole/parser.rb', line 43 def allowed_schemes @allowed_schemes end |
#extensions=(value) ⇒ Object (writeonly)
Non-standard wiki text extensions enabled? E.g. underlined, deleted text etc
47 48 49 |
# File 'lib/creole/parser.rb', line 47 def extensions=(value) @extensions = value end |
#no_escape=(value) ⇒ Object (writeonly)
Disable url escaping for local links Escaping: [[/Test]] –> %2FTest No escaping: [[/Test]] –> Test
53 54 55 |
# File 'lib/creole/parser.rb', line 53 def no_escape=(value) @no_escape = value end |
Instance Method Details
#extensions? ⇒ Boolean
48 |
# File 'lib/creole/parser.rb', line 48 def extensions?; @extensions; end |
#no_escape? ⇒ Boolean
54 |
# File 'lib/creole/parser.rb', line 54 def no_escape?; @no_escape; end |
#to_html ⇒ Object
Convert CCreole text to HTML and return the result. The resulting HTML does not contain <html> and <body> tags.
Example:
parser = CreoleParser.new("**Hello //World//**", :extensions => true)
parser.to_html
#=> "<p><strong>Hello <em>World</em></strong></p>"
73 74 75 76 77 78 79 |
# File 'lib/creole/parser.rb', line 73 def to_html @out = '' @p = false @stack = [] parse_block(@text) @out end |