Guest User

Untitled

a guest
Nov 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. [6] (pry) main / Redcarpet: 1> cd Markdown
  2. [7] (pry) main / Redcarpet / Redcarpet::Markdown: 2> ls -M
  3. Redcarpet::Markdown#methods: render renderer
  4. [8] (pry) main / Redcarpet / Redcarpet::Markdown: 2> $ render
  5. Scanning and caching *.c files...
  6.  
  7. From: /Users/john/.rvm/gems/ruby-1.9.3-p194/gems/redcarpet-2.1.1/ext/redcarpet/rc_markdown.c (C Method):
  8. Number of lines: 44
  9. Owner: Redcarpet::Markdown
  10. Visibility: public
  11.  
  12. static VALUE rb_redcarpet_md_render(VALUE self, VALUE text)
  13. {
  14. VALUE rb_rndr;
  15. struct buf *output_buf;
  16. struct sd_markdown *markdown;
  17.  
  18. Check_Type(text, T_STRING);
  19.  
  20. rb_rndr = rb_iv_get(self, "@renderer");
  21. Data_Get_Struct(self, struct sd_markdown, markdown);
  22.  
  23. if (rb_respond_to(rb_rndr, rb_intern("preprocess")))
  24. text = rb_funcall(rb_rndr, rb_intern("preprocess"), 1, text);
  25. if (NIL_P(text))
  26. return Qnil;
  27.  
  28. #ifdef HAVE_RUBY_ENCODING_H
  29. {
  30. struct rb_redcarpet_rndr *renderer;
  31. Data_Get_Struct(rb_rndr, struct rb_redcarpet_rndr, renderer);
  32. renderer->options.active_enc = rb_enc_get(text);
  33. }
  34. #endif
  35.  
  36. /* initialize buffers */
  37. output_buf = bufnew(128);
  38.  
  39. /* render the magic */
  40. sd_markdown_render(
  41. output_buf,
  42. RSTRING_PTR(text),
  43. RSTRING_LEN(text),
  44. markdown);
  45.  
  46. /* build the Ruby string */
  47. text = redcarpet_str_new(output_buf->data, output_buf->size, rb_enc_get(text));
  48.  
  49. bufrelease(output_buf);
  50.  
  51. [9] (pry) main / Redcarpet / Redcarpet::Markdown: 2>
Add Comment
Please, Sign In to add comment