class MD4C::Parser
Public Class Methods
Source
static VALUE
rbm_cParser_m_initialize (int argc, VALUE *argv, VALUE self)
{
VALUE kwargs;
rb_scan_args (argc, argv, ":", &kwargs);
ID kwargs_ids[] = { PARSER_FLAGS };
VALUE kwargs_vals[sizeof (kwargs_ids) / sizeof (kwargs_ids[0])] = { 0 };
rb_get_kwargs (kwargs, kwargs_ids, 0,
sizeof (kwargs_ids) / sizeof (kwargs_ids[0]), kwargs_vals);
struct rbm_cParser *p = RTYPEDDATA_DATA (self);
*p = (struct rbm_cParser){ .flags = rbm_get_parser_flags (kwargs_vals) };
return self;
}
All flags are false by default, which means it is CommonMark.
Public Instance Methods
Source
# File sig/md4c.rbs, line(s) 73:92
def initialize: (
collapse_whitespace: bool,
permissive_atx_headers: bool,
permissive_url_autolinks: bool,
permissive_email_autolinks: bool,
no_indented_codeblocks: bool,
no_html_blocks: bool,
no_html_spans: bool,
tables: bool,
strikethrough: bool,
permissive_www_autolinks: bool,
task_lists: bool,
latex_math_spans: bool,
wiki_links: bool,
underline: bool,
hard_soft_breaks: bool,
permissive_autolinks: bool,
no_html: bool,
commonmark: bool,
github: bool) -> MD4C::Parser
Source
static VALUE
rbm_cParser_m_on_enter_block (VALUE self)
{
struct rbm_cParser *p = RTYPEDDATA_DATA (self);
return p->on_enter_block = rb_block_proc ();
}
Source
static VALUE
rbm_cParser_m_on_enter_span (VALUE self)
{
struct rbm_cParser *p = RTYPEDDATA_DATA (self);
return p->on_enter_span = rb_block_proc ();
}
Source
static VALUE
rbm_cParser_m_on_leave_block (VALUE self)
{
struct rbm_cParser *p = RTYPEDDATA_DATA (self);
return p->on_leave_block = rb_block_proc ();
}
Source
static VALUE
rbm_cParser_m_on_leave_span (VALUE self)
{
struct rbm_cParser *p = RTYPEDDATA_DATA (self);
return p->on_leave_span = rb_block_proc ();
}
Source
static VALUE
rbm_cParser_m_on_text (VALUE self)
{
struct rbm_cParser *p = RTYPEDDATA_DATA (self);
return p->on_text = rb_block_proc ();
}
Source
static VALUE
rbm_cParser_m_parse (VALUE self, VALUE source)
{
char *text = rb_string_value_ptr (&source);
long size = RSTRING_LEN (source);
struct rbm_cParser *p = RTYPEDDATA_DATA (self);
MD_PARSER parser = { .flags = p->flags,
.enter_block = rbm_callback_enter_block,
.leave_block = rbm_callback_leave_block,
.enter_span = rbm_callback_enter_span,
.leave_span = rbm_callback_leave_span,
.text = rbm_callback_text };
int result = md_parse (text, (MD_SIZE)size, &parser, p);
if (result == -1)
rb_raise (rbm_eError, "runtime error, such as memory fails");
if (result != 0)
rb_raise (rbm_eError, "parse failed");
return RUBY_Qnil;
}