Skip to content
Browse files

Merge branch 'release/0.3.4'

  • Loading branch information...
2 parents aae4fbf + 6fe73e8 commit 85238828221a199625e7175acf80b5eebf8c8d45 @chobie committed
Showing with 900 additions and 116 deletions.
  1. +0 −17 .gitignore
  2. +61 −0 Changelog
  3. +27 −3 README.md
  4. +2 −12 Rakefile
  5. +28 −15 config.m4
  6. +77 −66 package.xml
  7. +2 −1 php_sundown.c
  8. +6 −0 php_sundown.h
  9. +608 −0 render_html_toc.c
  10. +2 −2 render_xhtml.c
  11. +29 −0 sundown_markdown.c
  12. +58 −0 tests/003-advanced-set-render.phpt
View
17 .gitignore
@@ -1,22 +1,5 @@
*.o
-# ignore sundown sources.
-autolink.c
-autolink.h
-buffer.c
-buffer.h
-houdini.h
-houdini_href_e.c
-houdini_html_e.c
-html.c
-html.h
-html_blocks.h
-html_smartypants.c
-stack.c
-stack.h
-markdown.c
-markdown.h
-
# ignore phpized files
Makefile.global
acinclude.m4
View
61 Changelog
@@ -0,0 +1,61 @@
+2010-04-22 Shuhei Tanuma <chobieeee@php.net>
+
+ * bumped up 0.3.3:
+
+ [summary]
+ * fix #16 missing space_after_headers extension
+
+2010-04-02 Shuhei Tanuma <chobieeee@php.net>
+
+ * bumped up 0.3.1:
+
+ [summary]
+ * fixed overloading callback methods.
+ * fixed segfault when calling render method more than once.
+ * implement more test cases.
+
+2010-03-04 Shuhei Tanuma <chobieeee@php.net>
+
+ * bumped up 0.3.0:
+
+ change callback method name for PECL standards.
+ php-sundown aims to implement more test cases until next minor version release.
+
+ [summary]
+ * change callback method names for PECL standards
+ * fix segfault when using XHTML render
+ * fix getting render flags issue
+ * improve Sundown\Markdown
+ don'd read render / extensions property directly.
+ * fix memory leaks
+ * implement more test cases.
+
+2010-03-04 Shuhei Tanuma <chobieeee@php.net>
+
+ * bumped up 0.2.0:
+
+ * checks extensions and render flags value.
+
+ 0.1.0b release only checks specified key exist. Now, it also checks their value.
+
+ * added useful methods.
+
+ array Sundown\Render\Base::getRenderFlags()
+ void Sundown\Render\Base::setRenderFlags(array $render_flags)
+
+ array Sundown\Markdown::getExtensions()
+ void Sundown\Markdown::setExtensions(array $extensions)
+ Sundown\Render\Base Sundown\Markdown::getRender()
+
+ * update bundled Sundown library
+
+ [summary]
+ * Fix segfault on empty link refs
+ * Escape html inside table of contents.
+ * hanging whitespace breaks tables
+
+
+2010-02-05 Shuhei Tanuma <chobieeee@php.net>
+
+ * bumped up 0.2.0:
+ - Initial PECL Sundown release.
View
30 README.md
@@ -34,9 +34,11 @@ Install for developpers
git clone https://github.com/chobie/php-sundown.git php-sundown -b development
cd php-sundown
- # this command will fetch submodule and copy neccesally files to src dir. and compile it.
- rake submodule compile
- sudo rake install
+ git submodule init && git submodule update
+ phpze
+ ./configure
+ make
+ make install
# please add following line to your php.ini
# extension=sundown.so
@@ -229,6 +231,28 @@ $md = new \Sundown\Markdown(\Sundown\Render\HTML,array("autolink"=>true));
$md->getRender()->setRenderFlags(array("filter_html"=>true));
````
+### \Sundown\Markdown::setRender(Sundown\Render\Base $render)
+
+##### *Description*
+
+set render instance.
+
+##### *Parameters*
+
+*render*: render instance
+
+##### *Return Value*
+
+* void
+
+##### *Example*
+
+````php
+<?php
+$md = new \Sundown\Markdown(\Sundown\Render\HTML,array("autolink"=>true));
+$render2 = \Sundown\Render\HTML();
+$md->setRender($render2);
+````
### \Sundown\Render\Base
View
14 Rakefile
@@ -32,17 +32,8 @@ task "test:conformance" do
end
desc 'Gather required Sundown sources into extension directory'
-task :gather => 'sundown/src/markdown.h' do |t|
- files =
- FileList[
- 'sundown/src/{markdown,buffer,stack,autolink,html_blocks}.h',
- 'sundown/src/{markdown,buffer,stack,autolink}.c',
- 'sundown/html/{html,html_smartypants,houdini_html_e,houdini_href_e}.c',
- 'sundown/html/{html,houdini}.h',
- ]
- cp files, './',
- :preserve => true,
- :verbose => true
+task :gather do
+ abort "gather task become deprecated. now you don't need call this task."
end
file 'sundown/src/markdown.h' do |t|
@@ -52,5 +43,4 @@ end
task :submodule do
sh "git submodule init"
sh "git submodule update"
- Rake::Task['gather'].invoke
end
View
43 config.m4
@@ -2,19 +2,32 @@ PHP_ARG_ENABLE(sundown,Whether to enable the "sundown" extension,
[ --enable-sundown Enable "sundown" extension support])
if test $PHP_SUNDOWN != "no"; then
- PHP_NEW_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 \
- , $ext_shared)
+ SUNDOWN_SOURCES="
+php_sundown.c
+sundown_markdown.c
+render_base.c
+render_html.c
+render_xhtml.c
+render_html_toc.c
+sundown/src/buffer.c
+sundown/src/markdown.c
+sundown/src/autolink.c
+sundown/src/stack.c
+sundown/html/html.c
+sundown/html/html_smartypants.c
+sundown/html/houdini_href_e.c
+sundown/html/houdini_html_e.c
+"
+
+ PHP_NEW_EXTENSION(sundown,$SUNDOWN_SOURCES, $ext_shared)
+ CFLAGS=" -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration"
+ PHP_SUBST([CFLAGS])
+
+ PHP_ADD_BUILD_DIR([$ext_builddir/sundown/src])
+ PHP_ADD_BUILD_DIR([$ext_builddir/sundown/html])
+
+ PHP_ADD_INCLUDE([$ext_srcdir/sundown/src])
+ PHP_ADD_INCLUDE([$ext_srcdir/sundown/html])
+ PHP_ADD_INCLUDE([$ext_builddir/sundown/src])
+ PHP_ADD_INCLUDE([$ext_builddir/sundown/html])
fi
View
143 package.xml
@@ -15,10 +15,10 @@ PECL Sundown provides straight forward object oriented Markdown API and customiz
<email>chobieeee@php.net</email>
<active>yes</active>
</lead>
- <date>2012-04-22</date>
+ <date>2012-05-14</date>
<version>
- <release>0.3.3</release>
- <api>0.3.0</api>
+ <release>0.3.4</release>
+ <api>0.3.4</api>
</version>
<stability>
<release>beta</release>
@@ -26,10 +26,13 @@ PECL Sundown provides straight forward object oriented Markdown API and customiz
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
-bumped up 0.3.3
+bumped up 0.3.4
[summary]
- * fix #16 missing space_after_headers extension
+ * add Sundown\Render\HTML_TOC render.
+ * add Sundown\Markdown::setRender(Sundown\Render\Base $render);
+ * improve build script.
+ * add Changelog, adjust package.xml
</notes>
<contents>
<dir name="/">
@@ -38,23 +41,6 @@ bumped up 0.3.3
<file role="doc" name="LICENSE" />
<file role="doc" name="README.md" />
<file role="doc" name="Rakefile" />
- <!-- bundled Sundowon library -->
- <file role="src" name="autolink.c" />
- <file role="src" name="autolink.h" />
- <file role="src" name="buffer.c" />
- <file role="src" name="buffer.h" />
- <file role="src" name="houdini.h" />
- <file role="src" name="houdini_href_e.c" />
- <file role="src" name="houdini_html_e.c" />
- <file role="src" name="html.h" />
- <file role="src" name="html.c" />
- <file role="src" name="html_blocks.h" />
- <file role="src" name="html_smartypants.c" />
- <file role="src" name="markdown.c" />
- <file role="src" name="markdown.h" />
- <file role="src" name="stack.c" />
- <file role="src" name="stack.h" />
- <!-- /bundled Sundown library -->
<file role="src" name="config.m4" />
<file role="src" name="config.w32" />
<file role="src" name="php_sundown.h" />
@@ -62,25 +48,64 @@ bumped up 0.3.3
<file role="src" name="sundown_markdown.c" />
<file role="src" name="render_base.c" />
<file role="src" name="render_html.c" />
+ <file role="src" name="render_html_toc.c" />
<file role="src" name="render_xhtml.c" />
<dir name="tests">
- <file role="test" name="001.phpt" />
- <file role="test" name="002-basic-constructor-arguments.phpt" />
- <file role="test" name="002-basic-to_html.phpt" />
- <file role="test" name="002-constructor-arguments.phpt" />
- <file role="test" name="003-advanced-constructor.phpt" />
- <file role="test" name="003-advanced-render-html-block_code.phpt" />
- <file role="test" name="003-advanced-render-html-block_html.phpt" />
- <file role="test" name="003-advanced-render-html-block_quote.phpt" />
- <file role="test" name="003-advanced-render-html-header.phpt" />
- <file role="test" name="003-advanced-render-html-list.phpt" />
- <file role="test" name="003-advanced-render-html-paragraph.phpt" />
- <file role="test" name="003-to_html.phpt" />
- </dir>
+ <file role="test" name="001.phpt" />
+ <file role="test" name="002-basic-constructor-arguments.phpt" />
+ <file role="test" name="002-basic-enabled-extensions.phpt" />
+ <file role="test" name="002-basic-enabled-render-flags.phpt" />
+ <file role="test" name="002-basic-to_html.phpt" />
+ <file role="test" name="002-constructor-arguments.phpt" />
+ <file role="test" name="003-advanced-constructor.phpt" />
+ <file role="test" name="003-advanced-enabled-extensions.phpt" />
+ <file role="test" name="003-advanced-enabled-render-flags.phpt" />
+ <file role="test" name="003-advanced-get-extensions.phpt" />
+ <file role="test" name="003-advanced-get-render.phpt" />
+ <file role="test" name="003-advanced-render-base-get_render_flags.phpt" />
+ <file role="test" name="003-advanced-render-base-set_render_flags.phpt" />
+ <file role="test" name="003-advanced-render-html-block_code.phpt" />
+ <file role="test" name="003-advanced-render-html-block_html.phpt" />
+ <file role="test" name="003-advanced-render-html-block_quote.phpt" />
+ <file role="test" name="003-advanced-render-html-header.phpt" />
+ <file role="test" name="003-advanced-render-html-list.phpt" />
+ <file role="test" name="003-advanced-render-html-paragraph.phpt" />
+ <file role="test" name="003-advanced-set-extensions.phpt" />
+ <file role="test" name="003-advanced-set-render.phpt" />
+ <file role="test" name="003-to_html.phpt" />
+ <file role="test" name="004-render-extensions-fenced_code_blocks.phpt" />
+ <file role="test" name="004-render-extensions-space_after_headers.phpt" />
+ <file role="test" name="004-render-html.phpt" />
+ <file role="test" name="005-render-xhtml.phpt" />
+ <file role="test" name="006-render-custom-codeblock.phpt" />
+ <file role="test" name="999-regression-no12.phpt" />
+ </dir>
<dir name="docs">
<file role="doc" name="ExtensionsAndRenderFlags.md" />
<file role="doc" name="Render.md" />
</dir>
+ <dir name="sundown">
+ <file role="doc" name="README.markdown" />
+ <dir name="src">
+ <file role="src" name="autolink.c" />
+ <file role="src" name="autolink.h" />
+ <file role="src" name="buffer.c" />
+ <file role="src" name="buffer.h" />
+ <file role="src" name="html_blocks.h" />
+ <file role="src" name="markdown.c" />
+ <file role="src" name="markdown.h" />
+ <file role="src" name="stack.c" />
+ <file role="src" name="stack.h" />
+ </dir>
+ <dir name="html">
+ <file role="src" name="houdini.h" />
+ <file role="src" name="houdini_href_e.c" />
+ <file role="src" name="houdini_html_e.c" />
+ <file role="src" name="html.h" />
+ <file role="src" name="html.c" />
+ <file role="src" name="html_smartypants.c" />
+ </dir>
+ </dir>
</dir>
</contents>
<dependencies>
@@ -104,6 +129,23 @@ bumped up 0.3.3
<api>beta</api>
</stability>
<version>
+ <release>0.3.3</release>
+ <api>0.3.0</api>
+ </version>
+ <date>2012-04-22</date>
+ <notes>
+bumped up 0.3.3
+
+[summary]
+ * fix #16 missing space_after_headers extension
+ </notes>
+ </release>
+ <release>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <version>
<release>0.3.2</release>
<api>0.3.0</api>
</version>
@@ -115,7 +157,6 @@ bumped up 0.3.2
* use no_intra_emphasis instead of no_intraemphasis
</notes>
</release>
-
<release>
<stability>
<release>beta</release>
@@ -199,36 +240,6 @@ Sundown\Render\Base Sundown\Markdown::getRender()
<api>beta</api>
</stability>
<version>
- <release>0.2.0</release>
- <api>0.2.0</api>
- </version>
- <date>2012-02-21</date>
- <notes>
-* checks extensions and render flags value.
-
-0.1.0b release only checks specified key exist. Now, it also checks their value.
-
-* added useful methods.
-
-array Sundown\Render\Base::getRenderFlags()
-void Sundown\Render\Base::setRenderFlags(array $render_flags)
-
-array Sundown\Markdown::getExtensions()
-void Sundown\Markdown::setExtensions(array $extensions)
-Sundown\Render\Base Sundown\Markdown::getRender()
-
-[summary]
- * Fix segfault on empty link refs
- * Escape html inside table of contents.
- * hanging whitespace breaks tables
- </notes>
- </release>
- <release>
- <stability>
- <release>beta</release>
- <api>beta</api>
- </stability>
- <version>
<release>0.1.0b</release>
<api>0.1.0b</api>
</version>
View
3 php_sundown.c
@@ -20,9 +20,9 @@
#include "php_sundown.h"
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);
extern void php_sundown_markdown_init(TSRMLS_D);
-extern void php_sundown_markdown_init(TSRMLS_D);
zend_class_entry *sundown_class_entry;
@@ -217,6 +217,7 @@ PHP_MINIT_FUNCTION(sundown) {
php_sundown_render_base_init(TSRMLS_C);
php_sundown_render_html_init(TSRMLS_C);
php_sundown_render_xhtml_init(TSRMLS_C);
+ php_sundown_render_html_toc_init(TSRMLS_C);
php_sundown_markdown_init(TSRMLS_C);
REGISTER_NS_STRING_CONSTANT(ZEND_NS_NAME("Sundown","Render"), "HTML", "Sundown\\Render\\HTML", CONST_CS | CONST_PERSISTENT);
View
6 php_sundown.h
@@ -60,6 +60,12 @@ typedef struct{
zend_object zo;
struct html_renderopt html;
struct sd_callbacks cb;
+} php_sundown_render_html_toc_t;
+
+typedef struct{
+ zend_object zo;
+ struct html_renderopt html;
+ struct sd_callbacks cb;
} php_sundown_render_xhtml_t;
typedef struct{
View
608 render_html_toc.c
@@ -0,0 +1,608 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2011 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Shuhei Tanuma <chobieee@gmail.com> |
+ +----------------------------------------------------------------------+
+ */
+
+
+#include "php_sundown.h"
+#include "html.h"
+
+static void php_sundown_render_html_toc_free_storage(php_sundown_render_html_toc_t *obj TSRMLS_DC)
+{
+ zend_object_std_dtor(&obj->zo TSRMLS_CC);
+ efree(obj);
+}
+
+zend_object_value php_sundown_render_html_toc_new(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value retval;
+ php_sundown_render_html_toc_t *obj;
+ zval *tmp;
+
+ obj = ecalloc(1, sizeof(*obj));
+ zend_object_std_init( &obj->zo, ce TSRMLS_CC);
+#if ZEND_MODULE_API_NO >= 20100525
+ object_properties_init(&(obj->zo), ce);
+#else
+ zend_hash_copy(obj->zo.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+#endif
+
+ retval.handle = zend_objects_store_put(obj,
+ (zend_objects_store_dtor_t)zend_objects_destroy_object,
+ (zend_objects_free_object_storage_t)php_sundown_render_html_toc_free_storage,
+ NULL TSRMLS_CC);
+ retval.handlers = zend_get_std_object_handlers();
+ return retval;
+}
+
+zend_class_entry *sundown_render_html_toc_class_entry;
+extern zend_class_entry *sundown_render_base_class_entry;
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc___construct, 0, 0, 1)
+ ZEND_ARG_INFO(0, render_flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_block_code, 0, 0, 2)
+ ZEND_ARG_INFO(0, language)
+ ZEND_ARG_INFO(0, code)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_block_quote, 0, 0, 1)
+ ZEND_ARG_INFO(0, quote)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_block_html, 0, 0, 1)
+ ZEND_ARG_INFO(0, raw_html)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_header, 0, 0, 2)
+ ZEND_ARG_INFO(0, htext)
+ ZEND_ARG_INFO(0, header_level)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_hrule, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_list_box, 0, 0, 2)
+ ZEND_ARG_INFO(0, contents)
+ ZEND_ARG_INFO(0, list_type)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_list_item, 0, 0, 2)
+ ZEND_ARG_INFO(0, text)
+ ZEND_ARG_INFO(0, list_type)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_paragraph, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_table, 0, 0, 2)
+ ZEND_ARG_INFO(0, header)
+ ZEND_ARG_INFO(0, body)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_table_row, 0, 0, 1)
+ ZEND_ARG_INFO(0, content)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_table_cell, 0, 0, 2)
+ ZEND_ARG_INFO(0, content)
+ ZEND_ARG_INFO(0, alignment)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_autolink, 0, 0, 2)
+ ZEND_ARG_INFO(0, link)
+ ZEND_ARG_INFO(0, link_type)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_codespan, 0, 0, 1)
+ ZEND_ARG_INFO(0, code)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_double_emphasis, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_emphasis, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_image, 0, 0, 3)
+ ZEND_ARG_INFO(0, link)
+ ZEND_ARG_INFO(0, title)
+ ZEND_ARG_INFO(0, alt_text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_linebreak, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_link, 0, 0, 3)
+ ZEND_ARG_INFO(0, link)
+ ZEND_ARG_INFO(0, title)
+ ZEND_ARG_INFO(0, content)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_raw_html, 0, 0, 1)
+ ZEND_ARG_INFO(0, raw_html)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_triple_emphasis, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_strikethrough, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_superscript, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_entity, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_normal_text, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_doc_header, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_doc_footer, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_html_toc_postprocess, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+/* {{{ proto stirng Sundown\Render\HTML_TOC::blockCode($language, $code)
+*/
+PHP_METHOD(sundown_render_html_toc, blockCode)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::blockQuote($quote)
+*/
+PHP_METHOD(sundown_render_html_toc, blockQuote)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::blockHtml()
+*/
+PHP_METHOD(sundown_render_html_toc, blockHtml)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::header($htext,$header_level)
+*/
+PHP_METHOD(sundown_render_html_toc, header)
+{
+ char *htext;
+ int htext_len;
+ long header_level;
+ struct buf *input, *output;
+ php_sundown_buffer_t *object;
+ php_sundown_render_html_toc_t *html;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "sl",&htext, &htext_len, &header_level) == FAILURE) {
+ return;
+ }
+
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_sundown_render_base_t *base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ input = str2buf(htext, htext_len);
+ output = bufnew(128);
+ html->cb.header(output,input,header_level, &base->html);
+ bufrelease(input);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::hrule()
+*/
+PHP_METHOD(sundown_render_html_toc, hrule)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::listBox($contents, $list_type)
+*/
+PHP_METHOD(sundown_render_html_toc, listBox)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::listItem($text, $list_type)
+*/
+PHP_METHOD(sundown_render_html_toc, listItem)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::paragraph($text)
+*/
+PHP_METHOD(sundown_render_html_toc, paragraph)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::table($header, $body)
+*/
+PHP_METHOD(sundown_render_html_toc, table)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::tableRow($content)
+*/
+PHP_METHOD(sundown_render_html_toc, tableRow)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::tableCell($content, $alignment)
+*/
+PHP_METHOD(sundown_render_html_toc, tableCell)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::autolink($link, $link_type)
+*/
+PHP_METHOD(sundown_render_html_toc, autolink)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::codespan($code)
+*/
+PHP_METHOD(sundown_render_html_toc, codespan)
+{
+ char *code;
+ int code_len;
+ struct buf *input, *output;
+ php_sundown_buffer_t *object;
+ php_sundown_render_html_toc_t *html;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "s", &code, &code_len) == FAILURE) {
+ return;
+ }
+
+ input = str2buf(code, code_len);
+ output = bufnew(128);
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ html->cb.codespan(output,input, &html->html);
+ bufrelease(input);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::doubleEmphasis($text)
+*/
+PHP_METHOD(sundown_render_html_toc, doubleEmphasis)
+{
+ char *text;
+ int text_len;
+ struct buf *input, *output;
+ php_sundown_buffer_t *object;
+ php_sundown_render_html_toc_t *html;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "s",&text, &text_len) == FAILURE) {
+ return;
+ }
+
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_sundown_render_base_t *base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);\
+ input = str2buf(text, text_len);
+ output = bufnew(128);
+ html->cb.double_emphasis(output,input, &base->html);
+ bufrelease(input);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::emphasis($text)
+*/
+PHP_METHOD(sundown_render_html_toc, emphasis)
+{
+ char *text;
+ int text_len;
+ struct buf *input, *output;
+ php_sundown_buffer_t *object;
+ php_sundown_render_html_toc_t *html;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "s", &text, &text_len) == FAILURE) {
+ return;
+ }
+
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_sundown_render_base_t *base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ input = str2buf(text, text_len);
+ output = bufnew(128);
+ html->cb.emphasis(output,input, &base->html);
+ bufrelease(input);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::image($link, $title, $alt_text)
+*/
+PHP_METHOD(sundown_render_html_toc, image)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::linebreak()
+*/
+PHP_METHOD(sundown_render_html_toc, linebreak)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::link($link,$title,$content)
+*/
+PHP_METHOD(sundown_render_html_toc, link)
+{
+ char *link, *title, *content;
+ int link_len, title_len, content_len;
+ struct buf *m_link, *m_title, *m_content, *output;
+ php_sundown_buffer_t *object;
+ php_sundown_render_html_toc_t *html;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "sss",&link, &link_len, &title, &title_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ m_link = str2buf(link, link_len);
+ m_title = str2buf(title, title_len);
+ m_content = str2buf(content, content_len);
+ output = bufnew(128);
+ html->cb.link(output,m_link, m_title, m_content, &html->html);
+ bufrelease(m_link);
+ bufrelease(m_title);
+ bufrelease(m_content);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::rawHtml($raw_html)
+*/
+PHP_METHOD(sundown_render_html_toc, rawHtml)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::tripleEmphasis($text)
+*/
+PHP_METHOD(sundown_render_html_toc, tripleEmphasis)
+{
+ char *text;
+ int text_len;
+ struct buf *input, *output;
+ php_sundown_buffer_t *object;
+ php_sundown_render_html_toc_t *html;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "s", &text, &text_len) == FAILURE) {
+ return;
+ }
+
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ input = str2buf(text, text_len);
+ output = bufnew(128);
+ html->cb.triple_emphasis(output,input, &html->html);
+ bufrelease(input);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::strikethrough($text)
+*/
+PHP_METHOD(sundown_render_html_toc, strikethrough)
+{
+ char *text;
+ int text_len;
+ struct buf *input, *output;
+ php_sundown_render_html_toc_t *html;
+ php_sundown_buffer_t *object;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "s", &text, &text_len) == FAILURE) {
+ return;
+ }
+
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ input = str2buf(text, text_len);
+ output = bufnew(128);
+ html->cb.strikethrough(output,input, &html->html);
+ bufrelease(input);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::superscript($text)
+*/
+PHP_METHOD(sundown_render_html_toc, superscript)
+{
+ char *text;
+ int text_len;
+ struct buf *input, *output;
+ php_sundown_buffer_t *object;
+ php_sundown_render_html_toc_t *html;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "s",&text, &text_len) == FAILURE) {
+ return;
+ }
+
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ input = str2buf(text, text_len);
+ output = bufnew(128);
+ html->cb.superscript(output,input, &html->html);
+ bufrelease(input);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::entity($text)
+*/
+PHP_METHOD(sundown_render_html_toc, entity)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::normalText($text)
+*/
+PHP_METHOD(sundown_render_html_toc, normalText)
+{
+ char *text;
+ int text_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "s",&text, &text_len) == FAILURE) {
+ return;
+ }
+
+ RETVAL_STRINGL(text,text_len,1);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::docHeader()
+*/
+PHP_METHOD(sundown_render_html_toc, docHeader)
+{
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::docFooter()
+*/
+PHP_METHOD(sundown_render_html_toc, docFooter)
+{
+ struct buf *output;
+ php_sundown_buffer_t *object;
+ php_sundown_render_html_toc_t *html;
+
+ html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ output = bufnew(128);
+ html->cb.doc_footer(output,&html->html);
+ RETVAL_STRINGL(output->data, output->size,1);
+ bufrelease(output);
+}
+/* }}} */
+
+/* {{{ proto string Sundown\Render\HTML_TOC::__construct($render_flags)
+*/
+PHP_METHOD(sundown_render_html_toc, __construct)
+{
+ php_sundown_render_html_toc_t *object;
+ struct php_sundown_renderopt_ex opt;
+ zval *render_flags = NULL, *c_flags = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "|z", &render_flags) == FAILURE) {
+ return;
+ }
+
+ if (render_flags != NULL && Z_TYPE_P(render_flags) == IS_ARRAY) {
+ ALLOC_INIT_ZVAL(c_flags);
+ ZVAL_ZVAL(c_flags, render_flags, 1, 0);
+ } else {
+ MAKE_STD_ZVAL(c_flags);
+ array_init(c_flags);
+ }
+ add_property_zval_ex(getThis(),"render_flags",sizeof("render_flags"),c_flags TSRMLS_CC);
+
+ object = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ sdhtml_toc_renderer(&object->cb, &opt.html);
+ opt.self = getThis();
+}
+/* }}} */
+
+static zend_function_entry php_sundown_render_html_toc_methods[] = {
+ PHP_ME(sundown_render_html_toc, __construct, arginfo_sundown_render_html_toc___construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
+ PHP_ME(sundown_render_html_toc, blockCode, arginfo_sundown_render_html_toc_block_code, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, blockQuote, arginfo_sundown_render_html_toc_block_quote, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, blockHtml, arginfo_sundown_render_html_toc_block_html, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, header, arginfo_sundown_render_html_toc_header, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, hrule, arginfo_sundown_render_html_toc_hrule, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, listBox, arginfo_sundown_render_html_toc_list_box, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, listItem, arginfo_sundown_render_html_toc_list_item, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, paragraph, arginfo_sundown_render_html_toc_paragraph, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, table, arginfo_sundown_render_html_toc_table, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, tableRow, arginfo_sundown_render_html_toc_table_row, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, tableCell, arginfo_sundown_render_html_toc_table_cell, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, autolink, arginfo_sundown_render_html_toc_autolink, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, codespan, arginfo_sundown_render_html_toc_codespan, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, doubleEmphasis, arginfo_sundown_render_html_toc_double_emphasis, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, emphasis, arginfo_sundown_render_html_toc_emphasis, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, image, arginfo_sundown_render_html_toc_image, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, linebreak, arginfo_sundown_render_html_toc_linebreak, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, link, arginfo_sundown_render_html_toc_link, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, rawHtml, arginfo_sundown_render_html_toc_raw_html, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, tripleEmphasis, arginfo_sundown_render_html_toc_triple_emphasis, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, strikethrough, arginfo_sundown_render_html_toc_strikethrough, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, superscript, arginfo_sundown_render_html_toc_superscript, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, entity, arginfo_sundown_render_html_toc_entity, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, normalText, arginfo_sundown_render_html_toc_normal_text, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, docHeader, arginfo_sundown_render_html_toc_doc_header, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_render_html_toc, docFooter, arginfo_sundown_render_html_toc_doc_footer, ZEND_ACC_PUBLIC)
+ {NULL,NULL,NULL}
+};
+
+void php_sundown_render_html_toc_init(TSRMLS_D)
+{
+ zend_class_entry ce;
+
+ INIT_NS_CLASS_ENTRY(ce, ZEND_NS_NAME("Sundown","Render"),"HTML_TOC", php_sundown_render_html_toc_methods);
+ sundown_render_html_toc_class_entry = zend_register_internal_class_ex(&ce, sundown_render_base_class_entry, NULL TSRMLS_CC);
+ sundown_render_html_toc_class_entry->create_object = php_sundown_render_html_toc_new;
+ zend_declare_property_null(sundown_render_html_toc_class_entry, "render_flags", sizeof("render_flags")-1, ZEND_ACC_PUBLIC TSRMLS_CC);
+}
View
4 render_xhtml.c
@@ -49,7 +49,7 @@ zend_object_value php_sundown_render_xhtml_new(zend_class_entry *ce TSRMLS_DC)
return retval;
}
-ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render___construct,0,0,1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_xhtml__construct,0,0,1)
ZEND_ARG_INFO(0, render_flags)
ZEND_END_ARG_INFO()
@@ -114,7 +114,7 @@ PHP_METHOD(sundown_render_xhtml, __construct)
static zend_function_entry php_sundown_render_xhtml_methods[] = {
- PHP_ME(sundown_render_xhtml, __construct, arginfo_sundown_render___construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
+ PHP_ME(sundown_render_xhtml, __construct, arginfo_sundown_render_xhtml__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
{NULL,NULL,NULL}
};
View
29 sundown_markdown.c
@@ -269,6 +269,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_markdown_render, 0, 0, 1)
ZEND_ARG_INFO(0, body)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_markdown_set_render, 0, 0, 1)
+ ZEND_ARG_INFO(0, render)
+ZEND_END_ARG_INFO()
+
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_markdown_set_extensions, 0, 0, 1)
ZEND_ARG_INFO(0, extension)
ZEND_END_ARG_INFO()
@@ -590,11 +595,35 @@ PHP_METHOD(sundown_markdown, getRender)
}
/* }}} */
+/* {{{ proto void string Sundown\Markdown::setRender(Sundown\Render\Base $render)
+*/
+PHP_METHOD(sundown_markdown, setRender)
+{
+ zval *render = NULL;
+ php_sundown_markdown_t *object = (php_sundown_markdown_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "z", &render) == FAILURE) {
+ return;
+ }
+
+ if (!instanceof_function_ex(Z_OBJCE_P(render), sundown_render_base_class_entry, 0 TSRMLS_CC)) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,"Render class must extend Sundown\\Render\\Base");
+ return;
+ }
+ zval_ptr_dtor(&object->render);
+ object->render = render;
+ Z_ADDREF_P(render);
+}
+/* }}} */
+
+
static zend_function_entry php_sundown_markdown_methods[] = {
PHP_ME(sundown_markdown, __construct, arginfo_sundown_markdown__construct, ZEND_ACC_PUBLIC)
PHP_ME(sundown_markdown, __destruct, NULL, ZEND_ACC_PUBLIC)
PHP_ME(sundown_markdown, render, arginfo_sundown_markdown_render, ZEND_ACC_PUBLIC)
PHP_ME(sundown_markdown, getRender, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(sundown_markdown, setRender, arginfo_sundown_markdown_set_render, ZEND_ACC_PUBLIC)
PHP_ME(sundown_markdown, getExtensions, NULL, ZEND_ACC_PUBLIC)
PHP_ME(sundown_markdown, setExtensions, arginfo_sundown_markdown_set_extensions, ZEND_ACC_PUBLIC)
PHP_ME(sundown_markdown, hasExtension, arginfo_sundown_markdown_has_extension, ZEND_ACC_PUBLIC)
View
58 tests/003-advanced-set-render.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Check for Sundown\Markdown::setRender
+--SKIPIF--
+<?php if (!extension_loaded("sundown")) print "skip"; ?>
+--FILE--
+<?php
+$render = new Sundown\Render\HTML_TOC();
+$data = <<<EOH
+# Hello World
+
+lorem ipsum dolar sit amet
+
+## the World, What a beautiful it is.
+
+lorem ipsum dolar sit amet
+
+EOH;
+
+$md = new Sundown\Markdown($render);
+echo "TOC_DATA\n";
+echo $md->render($data);
+echo "DATA\n";
+$md->setRender(new Sundown\Render\HTML(array("with_toc_data"=>true)));
+echo $md->render($data);
+$render = new Sundown\Render\HTML(array("with_toc_data"=>true));
+$md->setRender($render);
+echo $md->render($data);
+$md->setRender(new Sundown\Render\HTML(array("with_toc_data"=>true)));
+echo "#check render was not destroyed\n";
+if($render instanceof Sundown\Render\HTML) {
+echo "OK";
+} else {
+echo "FAILURE";
+}
+
+--EXPECT--
+TOC_DATA
+<ul>
+<li>
+<a href="#toc_0">Hello World</a>
+<ul>
+<li>
+<a href="#toc_1">the World, What a beautiful it is.</a>
+</li>
+</ul>
+</li>
+</ul>
+DATA
+<h1 id="toc_0">Hello World</h1>
+<p>lorem ipsum dolar sit amet</p>
+<h2 id="toc_1">the World, What a beautiful it is.</h2>
+<p>lorem ipsum dolar sit amet</p>
+<h1 id="toc_0">Hello World</h1>
+<p>lorem ipsum dolar sit amet</p>
+<h2 id="toc_1">the World, What a beautiful it is.</h2>
+<p>lorem ipsum dolar sit amet</p>
+#check render was not destroyed
+OK

0 comments on commit 8523882

Please sign in to comment.
Something went wrong with that request. Please try again.