Class: Greenmat::Render::HTML_TOC

Inherits:
Base
  • Object
show all
Defined in:
ext/greenmat/gm_render.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object



472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'ext/greenmat/gm_render.c', line 472

static VALUE rb_greenmat_htmltoc_init(int argc, VALUE *argv, VALUE self)
{
  struct rb_greenmat_rndr *rndr;
  unsigned int render_flags = HTML_TOC;
  VALUE hash, nesting_level = Qnil;

  Data_Get_Struct(self, struct rb_greenmat_rndr, rndr);

  if (rb_scan_args(argc, argv, "01", &hash) == 1) {
    Check_Type(hash, T_HASH);

    /* escape_html */
    if (rb_hash_aref(hash, CSTR2SYM("escape_html")) == Qtrue)
      render_flags |= HTML_ESCAPE;

    /* Nesting level */
    nesting_level = rb_hash_aref(hash, CSTR2SYM("nesting_level"));
  }

  sdhtml_toc_renderer(&rndr->callbacks, (struct html_renderopt *)&rndr->options.html, render_flags);
  rb_greenmat__overload(self, rb_cRenderHTML_TOC);

  if (!(NIL_P(nesting_level)))
    rndr->options.html.toc_data.nesting_level = NUM2INT(nesting_level);
  else
    rndr->options.html.toc_data.nesting_level = 6;

  return Qnil;
}