Module: CommonmarkerComrak
- Defined in:
- lib/commonmarkercomrak.rb,
lib/commonmarkercomrak/config.rb,
lib/commonmarkercomrak/version.rb,
lib/commonmarkercomrak/renderer.rb,
ext/commonmarkercomrak/commonmarkercomrak.c
Defined Under Namespace
Modules: Config Classes: Renderer
Constant Summary collapse
- VERSION =
"0.23.7"
Class Method Summary collapse
- .commonmark_to_html(rb_commonmark, rb_options) ⇒ Object
-
.to_html(text, options: CommonmarkerComrak::Config::OPTS) ⇒ Object
Public: Parses a CommonMark string into an HTML string.
Class Method Details
.commonmark_to_html(rb_commonmark, rb_options) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'ext/commonmarkercomrak/commonmarkercomrak.c', line 124
VALUE commonmark_to_html(VALUE self, VALUE rb_commonmark, VALUE rb_options) {
Check_Type(rb_commonmark, T_STRING);
Check_Type(rb_options, T_HASH);
char *commonmark = StringValueCStr(rb_commonmark);
comrak_options_t *options = comrak_options_new();
rb_hash_foreach(rb_options, iterate_options_hash, (VALUE)options);
comrak_str_t html = comrak_commonmark_to_html(commonmark, options);
VALUE rb_html = rb_utf8_str_new(html.data, html.len);
comrak_options_free(options);
comrak_str_free(html);
return rb_html;
}
|
.to_html(text, options: CommonmarkerComrak::Config::OPTS) ⇒ Object
Public: Parses a CommonMark string into an HTML string.
text - A String of text option - A Hash of render, parse, and extension options to transform the text.
Returns a String of converted HTML.
28 29 30 31 32 33 34 |
# File 'lib/commonmarkercomrak.rb', line 28 def self.to_html(text, options: CommonmarkerComrak::Config::OPTS) raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String) raise TypeError, "options must be a Hash; got a #{.class}!" unless .is_a?(Hash) opts = Config.() commonmark_to_html(text.encode("UTF-8"), opts) end |