Module: Redcarpet::Render::SmartyPants

Extended by:
SmartyPants
Included in:
SmartyHTML, SmartyPants
Defined in:
lib/redcarpet.rb,
ext/redcarpet/rc_render.c

Overview

SmartyPants Mixin module

Implements SmartyPants.postprocess, which performs smartypants replacements on the HTML file, once it has been fully rendered.

To add SmartyPants postprocessing to your custom renderers, just mixin the module ‘include SmartyPants`

You can also use this as a standalone SmartyPants implementation.

Example:

# Mixin
class CoolRenderer < HTML
  include SmartyPants
  # more code here
end

# Standalone
Redcarpet::Render::SmartyPants.render("you're")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.render(text) ⇒ Object



49
50
51
# File 'lib/redcarpet.rb', line 49

def self.render(text)
  postprocess text
end

Instance Method Details

#postprocess(text) ⇒ Object



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'ext/redcarpet/rc_render.c', line 402

static VALUE rb_redcarpet_smartypants_render(VALUE self, VALUE text)
{
	VALUE result;
	struct buf *output_buf;

	Check_Type(text, T_STRING);

	output_buf = bufnew(128);

	sdhtml_smartypants(output_buf, RSTRING_PTR(text), RSTRING_LEN(text));
	result = redcarpet_str_new(output_buf->data, output_buf->size);

	bufrelease(output_buf);
	return result;
}