Permalink
Browse files

re-enable SmartyPants feature.

now, SmartyPants post process filter implemented in Sundown\Render\Base. it enables when enable_pants property is true.

````
class SmartyPants extends Sundown\Render\HTML
{
	public $enable_pants = true;
}
````

you have to define own class and set ` public $enable_pants = true` if you want to use SmartyPants feature.
  • Loading branch information...
1 parent 665039a commit ecc3f862159acf54e24cc294f712eb21a650f80f @chobie committed Jan 8, 2012
Showing with 11 additions and 71 deletions.
  1. +11 −17 src/render_base.c
  2. +0 −54 src/render_html.c
View
@@ -58,9 +58,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render___construct,0,0,1)
ZEND_ARG_INFO(0, render_flags)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_base_enable_pants, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_base_block_code, 0, 0, 2)
ZEND_ARG_INFO(0, code)
ZEND_ARG_INFO(0, language)
@@ -181,15 +178,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_base_postprocess, 0, 0, 1)
ZEND_ARG_INFO(0, full_document)
ZEND_END_ARG_INFO()
-
-/* {{{ proto void enable_pants()
-*/
-PHP_METHOD(sundown_render_base, enable_pants)
-{
- RETURN_FALSE;
-}
-/* }}} */
-
/* {{{ proto void block_code($buffer, $code, $language)
*/
PHP_METHOD(sundown_render_base, block_code)
@@ -579,7 +567,7 @@ PHP_METHOD(sundown_render_base, doc_footer)
PHP_METHOD(sundown_render_base, preprocess)
{
char *text;
- long text_len;
+ int text_len;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE){
@@ -595,14 +583,21 @@ PHP_METHOD(sundown_render_base, preprocess)
PHP_METHOD(sundown_render_base, postprocess)
{
char *text;
- long text_len;
+ int text_len;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE){
return;
}
-
- RETVAL_STRINGL(text,text_len, 1);
+
+ if (Z_BVAL_P(zend_read_property(Z_OBJCE_P(getThis()), getThis(),"enable_pants",sizeof("enable_pants")-1, 1 TSRMLS_CC))) {
+ struct buf *smart_buf = bufnew(128);
+ sdhtml_smartypants(smart_buf, text,text_len);
+ RETVAL_STRINGL(smart_buf->data, smart_buf->size,1);
+ bufrelease(smart_buf);
+ } else {
+ RETVAL_STRINGL(text,text_len, 1);
+ }
}
/* }}} */
@@ -638,7 +633,6 @@ PHP_METHOD(sundown_render_base, __destruct)
static zend_function_entry php_sundown_render_base_methods[] = {
PHP_ME(sundown_render_base, __construct, arginfo_sundown_render___construct, ZEND_ACC_PUBLIC)
- PHP_ME(sundown_render_base, enable_pants, arginfo_sundown_render_base_enable_pants, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_base, block_code, arginfo_sundown_render_base_block_code, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_base, block_quote, arginfo_sundown_render_base_block_quote, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_base, block_html, arginfo_sundown_render_base_block_html, ZEND_ACC_PUBLIC)
View
@@ -59,9 +59,6 @@ extern zend_class_entry *sundown_render_base_class_entry;
ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_enable_pants, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_block_code, 0, 0, 2)
ZEND_ARG_INFO(0, code)
ZEND_ARG_INFO(0, language)
@@ -174,22 +171,6 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_doc_footer, 0, 0, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_preprocess, 0, 0, 1)
- ZEND_ARG_INFO(0, full_document)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_postprocess, 0, 0, 1)
- ZEND_ARG_INFO(0, full_document)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto void enable_pants()
-*/
-PHP_METHOD(sundown_render_html, enable_pants)
-{
- RETURN_FALSE;
-}
-/* }}} */
-
/* {{{ proto void block_code($buffer, $language, $code)
*/
PHP_METHOD(sundown_render_html, block_code)
@@ -827,38 +808,6 @@ PHP_METHOD(sundown_render_html, doc_footer)
}
/* }}} */
-/* {{{ proto void preprocess($full_document)
-*/
-PHP_METHOD(sundown_render_html, preprocess)
-{
- char *text;
- int text_len;
-
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
- "s", &text, &text_len) == FAILURE){
- return;
- }
-
- RETURN_STRINGL(text,text_len, 1);
-}
-/* }}} */
-
-/* {{{ proto void postprocess($full_document)
-*/
-PHP_METHOD(sundown_render_html, postprocess)
-{
- char *text;
- int text_len;
-
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
- "s", &text, &text_len) == FAILURE){
- return;
- }
-
- RETURN_STRINGL(text,text_len, 1);
-}
-/* }}} */
-
/* {{{ proto void __construct($render_flags)
*/
PHP_METHOD(sundown_render_html, __construct)
@@ -898,7 +847,6 @@ PHP_METHOD(sundown_render_html, __destruct)
static zend_function_entry php_sundown_render_html_methods[] = {
PHP_ME(sundown_render_html, __construct, arginfo_sundown_render_html___construct, ZEND_ACC_PUBLIC)
- PHP_ME(sundown_render_html, enable_pants, arginfo_sundown_render_html_enable_pants, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_html, block_code, arginfo_sundown_render_html_block_code, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_html, block_quote, arginfo_sundown_render_html_block_quote, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_html, block_html, arginfo_sundown_render_html_block_html, ZEND_ACC_PUBLIC)
@@ -925,8 +873,6 @@ static zend_function_entry php_sundown_render_html_methods[] = {
PHP_ME(sundown_render_html, normal_text, arginfo_sundown_render_html_normal_text, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_html, doc_header, arginfo_sundown_render_html_doc_header, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_html, doc_footer, arginfo_sundown_render_html_doc_footer, ZEND_ACC_PUBLIC)
- PHP_ME(sundown_render_html, preprocess, arginfo_sundown_render_html_preprocess, ZEND_ACC_PUBLIC)
- PHP_ME(sundown_render_html, postprocess, arginfo_sundown_render_html_postprocess, ZEND_ACC_PUBLIC)
PHP_ME(sundown_render_html, __destruct, NULL, ZEND_ACC_PUBLIC)
{NULL,NULL,NULL}
};

0 comments on commit ecc3f86

Please sign in to comment.