Class: Creole::Parser
- Inherits:
-
Object
- Object
- Creole::Parser
- Defined in:
- lib/creole/parser.rb
Instance Attribute Summary (collapse)
-
- (Object) allowed_schemes
Allowed url schemes Examples: http https ftp ftps.
-
- (Object) extensions
writeonly
Non-standard wiki text extensions enabled? E.g.
-
- (Object) no_escape
writeonly
Disable url escaping for local links Escaping: [[/Test]] –> %2FTest No escaping: [[/Test]] –> Test.
Instance Method Summary (collapse)
- - (Boolean) extensions?
-
- (Parser) initialize(text, options = {})
constructor
Create a new CreoleParser instance.
- - (Boolean) no_escape?
-
- (Object) to_html
Convert CCreole text to HTML and return the result.
Constructor Details
- (Parser) initialize(text, options = {})
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
- (Object) allowed_schemes
Allowed url schemes Examples: http https ftp ftps
43 44 45 |
# File 'lib/creole/parser.rb', line 43 def allowed_schemes @allowed_schemes end |
- (Object) extensions=(value) (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 |
- (Object) no_escape=(value) (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
- (Boolean) extensions?
48 |
# File 'lib/creole/parser.rb', line 48 def extensions?; @extensions; end |
- (Boolean) no_escape?
54 |
# File 'lib/creole/parser.rb', line 54 def no_escape?; @no_escape; end |
- (Object) to_html
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 |