Skip to content

Commit

Permalink
Merge branch 'release/0.3.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
chobie committed Jun 2, 2012
2 parents 9976d77 + 345dea1 commit b8ac4d3
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "sundown"]
path = sundown
url = https://github.com/tanoku/sundown.git
ignore = dirty
2 changes: 1 addition & 1 deletion CREDITS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sundown were made by...
-----------------------

Copyright (c) 2009, Natacha Porté
Copyright (c) 2009, Natacha Port�
Copyright (c) 2011, Vicent Marti

php-sundown inspired Redcarpet2 which is a ruby extension for parsing and rendering Markdown text.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,5 @@ documented at [ExtensionsAndRenderFlags.md](https://github.com/chobie/php-sundow
Contributors
------------
* Dominic Scheirlinck
* stealth35
* Shuhei Tanuma
10 changes: 9 additions & 1 deletion config.w32
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
ARG_WITH('sundown', 'sundown extension', 'no');

if (PHP_SUNDOWN != "no") {
if (CHECK_HEADER_ADD_INCLUDE("markdown.h", "CFLAGS_SUNDOWN", ".\\sundown\\src") &&
CHECK_HEADER_ADD_INCLUDE("html.h", "CFLAGS_SUNDOWN", ".\\sundown\\html")) {
ADD_SOURCES(configure_module_dirname + ".\\sundown\\src","buffer.c markdown.c autolink.c stack.c", "sundown");
ADD_SOURCES(configure_module_dirname + ".\\sundown\\html","html.c html_smartypants.c houdini_href_e.c houdini_html_e.c", "sundown");

EXTENSION("sundown", "php_sundown.c sundown_markdown.c render_base.c render_html.c render_xhtml.c buffer.c markdown.c html.c html_smartypants.c autolink.c stack.c houdini_href_e.c houdini_html_e.c");
EXTENSION("sundown", "php_sundown.c sundown_markdown.c render_base.c render_html.c render_html_toc.c render_xhtml.c");
} else {
WARNING( "sundown not enabled: headers not found");
}
ADD_EXTENSION_DEP('sundown','spl',true);
}
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<channel>pecl.php.net</channel>
<summary>Sundown is a fast, robust Markdown parsing library for PHP5</summary>
<description>Sundown is a fast, robust Markdown parsing library, originally created
by Natacha Porté and improved Vicent Marti.
by Natacha Porté and improved Vicent Marti.
this extension inspired Redcarpet ruby extension which created by Vicent.

PECL Sundown provides straight forward object oriented Markdown API and customizable Renders.
Expand Down
12 changes: 5 additions & 7 deletions php_sundown.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@


#include "php_sundown.h"
#include "ext/standard/info.h"

extern void php_sundown_render_base_init(TSRMLS_D);
extern void php_sundown_render_html_init(TSRMLS_D);
extern void php_sundown_render_html_toc_init(TSRMLS_D);
extern void php_sundown_render_xhtml_init(TSRMLS_D);
Expand Down Expand Up @@ -51,7 +53,6 @@ static void sundown__render(SundownRendererType render_type, INTERNAL_FUNCTION_P
unsigned int enabled_extensions = 0, render_flags = 0;
char *buffer;
int buffer_len = 0;
zend_class_entry *ce;
HashTable *table;

object = getThis();
Expand Down Expand Up @@ -221,19 +222,16 @@ PHP_MINIT_FUNCTION(sundown) {
php_sundown_markdown_init(TSRMLS_C);

REGISTER_NS_STRING_CONSTANT(ZEND_NS_NAME("Sundown","Render"), "HTML", "Sundown\\Render\\HTML", CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT(ZEND_NS_NAME("Sundown","Render"), "LIST_ORDERED", 1, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT(ZEND_NS_NAME("Sundown","Render"), "MKDA_EMAIL", MKDA_EMAIL, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT(ZEND_NS_NAME("Sundown","Render"), "MKDA_NORMAL", MKDA_NORMAL, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}


PHP_MINFO_FUNCTION(sundown)
{
php_printf("PHP Sundown Extension\n");
php_info_print_table_start();
php_info_print_table_row(2,"Sundown Support", "enabled");
php_info_print_table_row(2,"Sundown Version", "3361ebcd22089fe64860f96a7b6acaf18a55746e");
php_info_print_table_header(2,"Sundown Support", "enabled");
php_info_print_table_row(2,"Version", PHP_SUNDOWN_EXTVER);
php_info_print_table_row(2,"Sundown Version", SUNDOWN_VERSION);
php_info_print_table_end();
}

Expand Down
23 changes: 8 additions & 15 deletions php_sundown.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define PHP_SUNDOWN_H

#define PHP_SUNDOWN_EXTNAME "sundown"
#define PHP_SUNDOWN_EXTVER "0.1"
#define PHP_SUNDOWN_EXTVER "0.3.6-dev"

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand All @@ -12,16 +12,21 @@
#include "php.h"
#include "markdown.h"
#include "html.h"
#include "ext/spl/spl_exceptions.h"

#include "zend_interfaces.h"
#include "zend_exceptions.h"

#ifndef SUNDOWN_VERSION
#define SUNDOWN_VERSION UPSKIRT_VERSION
#endif

/* Define the entry point symbol
* Zend will use when loading this module
*/
extern zend_module_entry sundown_module_entry;
#define phpext_sundown_ptr &sundown_module_entry;

extern zend_class_entry *sundown_class_entry, *sundown_buffer_class_entry, *php_sundown_buffer_class_entry;
extern zend_class_entry *sundown_class_entry, *php_sundown_buffer_class_entry;

typedef enum
{
Expand All @@ -45,11 +50,6 @@ typedef struct{
zval *render;
} php_sundown_markdown_t;

typedef struct{
zend_object zo;
struct buf *buffer;
} php_sundown_buffer_t;

typedef struct{
zend_object zo;
struct html_renderopt html;
Expand All @@ -74,7 +74,6 @@ typedef struct{
} php_sundown_render_base_t;

#define SPAN_CALLBACK_EX(buffer,method_name, ...) {\
TSRMLS_FETCH();\
struct php_sundown_renderopt_ex *opt = (struct php_sundown_renderopt_ex*)opaque;\
zval func, *ret;\
\
Expand All @@ -95,7 +94,6 @@ typedef struct{


#define BLOCK_CALLBACK_EX(buffer,method_name, ...) {\
TSRMLS_FETCH();\
struct php_sundown_renderopt_ex *opt = (struct php_sundown_renderopt_ex*)opaque;\
zval func, *ret;\
\
Expand All @@ -115,7 +113,6 @@ typedef struct{
static int php_sundown_has_ext(HashTable *table, const char *name)
{
zval **data = NULL;
zval *ret = NULL;
int length = strlen(name) + 1;

if (zend_hash_find(table, name, length, (void **)&data) == SUCCESS) {
Expand All @@ -139,7 +136,6 @@ static int call_user_function_v(HashTable *function_table, zval **object_pp, zva
size_t i;
int ret;
zval **params;
zval *tmp;
TSRMLS_FETCH();

if (param_count > 0) {
Expand Down Expand Up @@ -213,7 +209,6 @@ static inline struct buf* str2buf(const char *text, size_t length)

static void php_sundown__get_render_flags(HashTable *table, unsigned int *render_flags_p)
{
TSRMLS_FETCH();
unsigned int render_flags = HTML_EXPAND_TABS;

/* filter_html */
Expand Down Expand Up @@ -258,7 +253,6 @@ static void php_sundown__get_render_flags(HashTable *table, unsigned int *render

static void php_sundown__get_extensions(HashTable *table, unsigned int *enabled_extensions_p)
{
TSRMLS_FETCH();
unsigned int extensions = 0;

/**
Expand Down Expand Up @@ -301,7 +295,6 @@ static void php_sundown__get_extensions(HashTable *table, unsigned int *enabled_

static void php_sundown__get_flags(HashTable *table, unsigned int *enabled_extensions_p, unsigned int *render_flags_p)
{
TSRMLS_FETCH();
unsigned int extensions = 0;
unsigned int render_flags = HTML_EXPAND_TABS;

Expand Down
30 changes: 5 additions & 25 deletions render_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ PHP_METHOD(sundown_render_base, blockCode)
{
char *code, *block_code;
int code_len, block_code_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"ss", &code, &code_len, &block_code, &block_code_len) == FAILURE) {
Expand All @@ -197,7 +196,6 @@ PHP_METHOD(sundown_render_base, blockQuote)
{
char *quote;
int quote_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &quote, &quote_len) == FAILURE) {
Expand All @@ -213,7 +211,6 @@ PHP_METHOD(sundown_render_base, blockHtml)
{
char *raw;
int raw_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &raw, &raw_len) == FAILURE) {
Expand All @@ -229,7 +226,6 @@ PHP_METHOD(sundown_render_base, header)
{
char *htext;
int htext_len, header_level;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"sl",&htext, &htext_len, &header_level) == FAILURE) {
Expand All @@ -256,7 +252,6 @@ PHP_METHOD(sundown_render_base, listBox)
char *contents;
int contents_len;
long list_type;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"sl", &contents, &contents_len, &list_type) == FAILURE) {
Expand All @@ -273,7 +268,6 @@ PHP_METHOD(sundown_render_base, listItem)
char *text;
int text_len;
long list_type;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"sl",&text, &text_len, &list_type) == FAILURE) {
Expand All @@ -289,8 +283,6 @@ PHP_METHOD(sundown_render_base, paragraph)
{
char *text;
int text_len;
zval *buffer;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE) {
Expand All @@ -306,7 +298,6 @@ PHP_METHOD(sundown_render_base, table)
{
char *header, *body;
int header_len, body_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"ss", &header, &header_len, &body, &body_len) == FAILURE) {
Expand All @@ -322,7 +313,6 @@ PHP_METHOD(sundown_render_base, tableRow)
{
char *contents;
int contents_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &contents, &contents_len) == FAILURE) {
Expand All @@ -338,7 +328,6 @@ PHP_METHOD(sundown_render_base, tableCell)
{
char *content, *alignment;
int content_len, alignment_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"ss", &content, &content_len, &alignment, &alignment_len) == FAILURE) {
Expand All @@ -355,7 +344,6 @@ PHP_METHOD(sundown_render_base, autolink)
char *link;
int link_len;
long link_type;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"sl",&link, &link_len, &link_type) == FAILURE) {
Expand All @@ -371,7 +359,6 @@ PHP_METHOD(sundown_render_base, codespan)
{
char *code;
int code_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &code, &code_len) == FAILURE) {
Expand All @@ -387,7 +374,6 @@ PHP_METHOD(sundown_render_base, doubleEmphasis)
{
char *text;
int text_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE) {
Expand All @@ -403,8 +389,6 @@ PHP_METHOD(sundown_render_base, emphasis)
{
char *text;
int text_len;
zval *buffer;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE) {
Expand All @@ -420,7 +404,6 @@ PHP_METHOD(sundown_render_base, image)
{
char *link, *title, *alt_text;
int link_len, title_len, alt_text_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"sss",&link, &link_len, &title, &title_len, &alt_text, &alt_text_len) == FAILURE) {
Expand All @@ -446,7 +429,6 @@ PHP_METHOD(sundown_render_base, link)
{
char *link, *title, *content;
int link_len, title_len, content_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"sss",&link, &link_len, &title, &title_len, &content, &content_len) == FAILURE) {
Expand All @@ -462,7 +444,6 @@ PHP_METHOD(sundown_render_base, rawHtml)
{
char *raw;
int raw_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &raw, &raw_len) == FAILURE) {
Expand All @@ -478,7 +459,6 @@ PHP_METHOD(sundown_render_base, tripleEmphasis)
{
char *text;
int text_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE) {
Expand All @@ -494,7 +474,6 @@ PHP_METHOD(sundown_render_base, strikethrough)
{
char *text;
int text_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE) {
Expand All @@ -510,7 +489,6 @@ PHP_METHOD(sundown_render_base, superscript)
{
char *text;
int text_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE) {
Expand All @@ -526,7 +504,6 @@ PHP_METHOD(sundown_render_base, entity)
{
char *text;
int text_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s", &text, &text_len) == FAILURE) {
Expand All @@ -542,7 +519,6 @@ PHP_METHOD(sundown_render_base, normalText)
{
char *text;
int text_len;
php_sundown_buffer_t *object;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"s",&text, &text_len) == FAILURE) {
Expand Down Expand Up @@ -637,7 +613,7 @@ PHP_METHOD(sundown_render_base, __construct)
PHP_METHOD(sundown_render_base, getRenderFlags)
{
if (Z_TYPE_P(zend_read_property(sundown_render_base_class_entry, getThis(),"render_flags",sizeof("render_flags")-1, 0 TSRMLS_CC)) != IS_NULL) {
zval *result, *tmp = NULL;
zval *tmp = NULL;

tmp = zend_read_property(sundown_render_base_class_entry, getThis(),"render_flags",sizeof("render_flags")-1, 0 TSRMLS_CC);
RETVAL_ZVAL(tmp, 1, 0);
Expand Down Expand Up @@ -719,4 +695,8 @@ void php_sundown_render_base_init(TSRMLS_D)
sundown_render_base_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
sundown_render_base_class_entry->create_object = php_sundown_render_base_new;
zend_declare_property_null(sundown_render_base_class_entry, "render_flags", sizeof("render_flags")-1, ZEND_ACC_PUBLIC TSRMLS_CC);

zend_declare_class_constant_long(sundown_render_base_class_entry, "LIST_ORDERED", sizeof("LIST_ORDERED")-1, 1 TSRMLS_CC);
zend_declare_class_constant_long(sundown_render_base_class_entry, "MKDA_EMAIL", sizeof("MKDA_EMAIL")-1, MKDA_EMAIL TSRMLS_CC);
zend_declare_class_constant_long(sundown_render_base_class_entry, "MKDA_NORMAL", sizeof("MKDA_NORMAL")-1, MKDA_NORMAL TSRMLS_CC);
}
Loading

0 comments on commit b8ac4d3

Please sign in to comment.