Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

oops sorry, Acutually i'll fix Upskirt signature.

$upskirt = new Upskirt(string $string [, array $extensions]);
$upskirt->to_html();
$upskirt->to_toc();
$upskirt->__toString();
  • Loading branch information...
commit 9346d7588398ee564a3bb88e54adbb8296d67002 1 parent 9a0bdc6
@chobie authored
Showing with 23 additions and 10 deletions.
  1. +3 −3 README.md
  2. +20 −7 src/phpskirt.c
View
6 README.md
@@ -34,6 +34,6 @@ Install
Example
-------
- $markdown = new Upskirt([array $extensions]);
- echo $markdown->to_html($string);
- echo $markdown->to_toc($string);
+ $markdown = new Upskirt(string $string [, array $extensions]);
+ echo $markdown->to_html();
+ echo $markdown->to_toc();
View
27 src/phpskirt.c
@@ -141,10 +141,8 @@ static void phpskirt__render(PHPSkirtRendererType render_type, INTERNAL_FUNCTION
int buffer_len = 0;
HashTable *table;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,"s",&buffer,&buffer_len) == FAILURE) {
- return;
- }
-
+ buffer = Z_STRVAL_P(zend_read_property(phpskirt_class_entry, getThis(),"data",sizeof("data")-1, 0 TSRMLS_CC));
+ buffer_len = strlen(buffer);
memset(&input_buf, 0x0, sizeof(struct buf));
input_buf.data = buffer;
@@ -184,19 +182,26 @@ static void phpskirt__render(PHPSkirtRendererType render_type, INTERNAL_FUNCTION
upshtml_free_renderer(&phpskirt_render);
}
+/* {{{ proto string __construct(string $string [, array $extensions])
+ setup Upskirt extension */
PHP_METHOD(phpskirt, __construct)
{
zval *extensions = NULL;
+ char *buffer;
+ int buffer_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,"|z",&extensions) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,"s|z",&buffer, &buffer_len, &extensions) == FAILURE) {
return;
}
+ add_property_string_ex(getThis(),"data",sizeof("data"),buffer,1 TSRMLS_CC);
if (extensions != NULL) {
add_property_zval_ex(getThis(),"extensions",sizeof("extensions"),extensions TSRMLS_CC);
}
}
-/* {{{ proto string to_html(string data)
+/* }}} */
+
+/* {{{ proto string to_html()
Returns converted HTML string */
PHP_METHOD(phpskirt, to_html)
{
@@ -204,7 +209,15 @@ PHP_METHOD(phpskirt, to_html)
}
/* }}} */
-/* {{{ proto string to_toc(string data)
+/* {{{ proto string __toString()
+ Returns converted HTML string */
+PHP_METHOD(phpskirt, __toString)
+{
+ phpskirt__render(PHPSKIRT_RENDER_HTML,INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ proto string to_toc()
Returns table of contents*/
PHP_METHOD(phpskirt, to_toc)
{
Please sign in to comment.
Something went wrong with that request. Please try again.