Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cataphract/php-discount
base: c90c5997a5
...
head fork: cataphract/php-discount
compare: 056d0c71c3
Checking mergeability… Don't worry, you can still create the pull request.
  • 8 commits
  • 16 files changed
  • 0 commit comments
  • 1 contributor
View
2  config.m4
@@ -15,6 +15,6 @@ if test "$PHP_DISCOUNT" != "no"; then
AC_DEFINE(HAVE_DISCOUNT, 1, [Whether you have discount markdown support])
PHP_SUBST(DISCOUNT_SHARED_LIBADD)
- PHP_NEW_EXTENSION(discount, discount.c markdowndoc_class.c markdowndoc_meth_callbacks.c markdowndoc_meth_document.c markdowndoc_meth_header.c markdowndoc_meth_input.c markdowndoc_meth_misc.c markdowndoc_meth_parts.c $discountlib_sources, $ext_shared,,-DUSE_DISCOUNT_DL=1 -DUSE_EXTRA_DL=1 -DTABSTOP=4 -DWITH_ID_ANCHOR=1 -DWITH_FENCED_CODE=1 -Wall -Wno-parentheses)
+ PHP_NEW_EXTENSION(discount, discount.c markdowndoc_class.c markdowndoc_meth_callbacks.c markdowndoc_meth_document.c markdowndoc_meth_header.c markdowndoc_meth_input.c markdowndoc_meth_misc.c markdowndoc_meth_parts.c $discountlib_sources, $ext_shared,,-DUSE_DISCOUNT_DL=1 -DUSE_EXTRA_DL=1 -DTABSTOP=4 -DWITH_ID_ANCHOR=1 -DWITH_FENCED_CODE=1 -DWITH_GITHUB_TAGS=1 -Wall -Wno-parentheses)
PHP_ADD_BUILD_DIR($ext_builddir/lib)
fi
View
2  lib/config.win32.h
@@ -8,6 +8,8 @@
#define USE_EXTRA_DL 1
#define TABSTOP 4
#define WITH_ID_ANCHOR 1
+#define WITH_FENCED_CODE 1
+#define WITH_GITHUB_TAGS 1
#define DWORD unsigned long
#define WORD unsigned short
View
2  lib/version.c
@@ -3,7 +3,7 @@
/* on merge: check against version.c.in */
/* on merge: obtain version from VERSION */
-const char markdown_version[] = "2.1.2.1-dev"
+const char markdown_version[] = "2.1.3.1-dev"
#if TABSTOP != 4
" TAB=" #TABSTOP
#endif
View
7 markdowndoc_class.c
@@ -84,6 +84,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_writefragment, 0, 0, 2)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_setreferenceprefix, 0, 0, 1)
+ ZEND_ARG_INFO(0, prefix)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_outstream, 0, 0, 1)
ZEND_ARG_INFO(0, markdown_outstream)
ZEND_END_ARG_INFO()
@@ -104,6 +108,7 @@ static zend_function_entry class_methods[] = {
PHP_ME(markdowndoc, dumpTree, arginfo_dumptree, ZEND_ACC_PUBLIC)
PHP_ME(markdowndoc, transformFragment, arginfo_transformfragment, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(markdowndoc, writeFragment, arginfo_writefragment, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ PHP_ME(markdowndoc, setReferencePrefix, arginfo_setreferenceprefix, ZEND_ACC_PUBLIC)
PHP_ME(markdowndoc, getTitle, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(markdowndoc, getAuthor, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(markdowndoc, getDate, arginfo_void, ZEND_ACC_PUBLIC)
@@ -193,7 +198,7 @@ discount_object* markdowndoc_get_object(zval *zobj, int require_compiled TSRMLS_
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC,
"Invalid state: the markdown document is not initialized");
return NULL;
- }
+ }
if (dobj->in_callback) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC,
View
26 markdowndoc_meth_misc.c
@@ -180,3 +180,29 @@ PHP_METHOD(markdowndoc, writeFragment)
RETURN_TRUE;
}
/* }}} */
+
+/* {{{ proto bool MarkdownDocument::setReferencePrefix(string) */
+PHP_METHOD(markdowndoc, setReferencePrefix)
+{
+ char *prefix;
+ int prefix_len;
+ discount_object *dobj;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
+ &prefix, &prefix_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+ if ((dobj = markdowndoc_get_object(getThis(), 0 TSRMLS_CC)) == NULL) {
+ RETURN_FALSE;
+ }
+ if (mkd_is_compiled(dobj->markdoc)) {
+ zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC,
+ "Invalid state: the markdown document has already been compiled");
+ RETURN_FALSE;
+ }
+
+ mkd_ref_prefix(dobj->markdoc, prefix);
+
+ RETURN_TRUE;
+}
+/* }}} */
View
1  markdowndoc_meth_misc.h
@@ -32,3 +32,4 @@ PHP_METHOD(markdowndoc, isCompiled);
PHP_METHOD(markdowndoc, dumpTree);
PHP_METHOD(markdowndoc, transformFragment);
PHP_METHOD(markdowndoc, writeFragment);
+PHP_METHOD(markdowndoc, setReferencePrefix);
View
2  php_discount.h
@@ -33,7 +33,7 @@
extern zend_module_entry discount_module_entry;
#define phpext_discount_ptr &discount_module_entry
-#define PHP_DISCOUNT_VERSION "0.2.0"
+#define PHP_DISCOUNT_VERSION "1.0.0-dev"
#ifdef PHP_WIN32
#define PHP_DISCOUNT_API __declspec(dllexport)
View
4 tests/compile_variation10.phpt
@@ -57,7 +57,7 @@ echo "\nDone.\n";
=====================
<p>aaa | bbbb
-&mdash;&mdash;&ndash;|&mdash;&mdash;&mdash;
+&mdash;&ndash;|&mdash;&mdash;
hello|sailor</p>
<p>But allow this</p>
@@ -70,5 +70,3 @@ hello|sailor</p>
Done.
---XFAIL--
-Extra line in table. Must be investigated. Probably caused by commits 0be590709c3a2df and b7b3141309e611.
View
8 tests/compile_variation18.phpt
@@ -2,8 +2,6 @@
MarkdownDocument::compile: test NODLIST flag (markdown style)
--COMMENT--
This is currently leaking memory.
---XFAIL--
-Failing. Check before release.
--SKIPIF--
<?php
if (!extension_loaded('discount'))
@@ -42,10 +40,8 @@ echo "\nDone.\n";
=====================
<p>Apple
-: Pomaceous fruit of plants of the genus Malus in</p>
-
-<pre><code>the family Rosaceae.
-</code></pre>
+: Pomaceous fruit of plants of the genus Malus in
+ the family Rosaceae.</p>
<p>Orange
: The fruit of an evergreen tree of the genus Citrus.</p>
View
8 tests/compile_variation19.phpt
@@ -4,8 +4,6 @@ MarkdownDocument::compile: test NODLIST flag (discount style)
<?php
if (!extension_loaded('discount'))
die('SKIP discount extension not loaded');
---XFAIL--
-Failing. Check before release.
--FILE--
<?php
$t = <<<EOD
@@ -32,10 +30,8 @@ echo "\nDone.\n";
</dl>
=====================
-<p>=hey!=</p>
-
-<pre><code>This is a definition list
-</code></pre>
+<p>=hey!=
+ This is a definition list</p>
Done.
View
12 tests/compile_variation3.phpt
@@ -4,8 +4,6 @@ MarkdownDocument::compile: test NOPANTS flag
<?php
if (!extension_loaded('discount'))
die('SKIP discount extension not loaded');
---XFAIL--
-Failing. Check before release.
--FILE--
<?php
$t = <<<EOD
@@ -20,8 +18,8 @@ And it's is
1/4th ? ¼th. Ditto for 1/4 (¼), 1/2 (½), 3/4ths (¾ths), and 3/4 (¾).
... becomes …
. . . also becomes …
--- becomes —
-- becomes – , but A-B remains A-B.
+--- becomes —
+-- becomes –
EOD;
$md = MarkdownDocument::createFromString($t);
@@ -48,7 +46,7 @@ And it&rsquo;s is
&hellip; becomes …
&hellip; also becomes …
&mdash; becomes —
-&ndash; becomes – , but A-B remains A-B.</p>
+&ndash; becomes –</p>
=====================
<p>``text'' is translated to “text”.
@@ -62,8 +60,8 @@ And it's is
1/4th ? ¼th. Ditto for 1/4 (¼), 1/2 (½), 3/4ths (¾ths), and 3/4 (¾).
... becomes
. . . also becomes
--- becomes
-- becomes , but A-B remains A-B.</p>
+--- becomes
+-- becomes</p>
Done.
View
10 tests/compile_variation5.phpt
@@ -2,8 +2,6 @@
MarkdownDocument::compile: test STRICT flag
--COMMENT--
Combination of NOSUPERSCRIPT, NORELAXED, NOSTRIKETHROUGH, NODLIST, NOALPHALIST, NODIVQUOTE and MKD_NOTABLES
---XFAIL--
-Failing. Check before release.
--SKIPIF--
<?php
if (!extension_loaded('discount'))
@@ -91,15 +89,13 @@ echo "\nDone.\n";
<p>. sdfsd
. wesdf</p>
-<p>=hey!=</p>
-
-<pre><code>This is a definition list
-</code></pre>
+<p>=hey!=
+ This is a definition list</p>
<blockquote><p>%class%</p></blockquote>
<p>aaa | bbbb
-&mdash;&mdash;&ndash;|&mdash;&mdash;&mdash;
+&mdash;&ndash;|&mdash;&mdash;
hello|sailor</p>
View
29 tests/pp_fenced_code.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Compile-time options: check WITH_FENCED_CODE effect
+--SKIPIF--
+<?php
+if (!extension_loaded('discount'))
+ die('SKIP discount extension not loaded');
+--FILE--
+<?php
+$t = <<<EOD
+First line
+
+~~~
+My code
+Foo bar
+~~~
+EOD;
+
+$md = MarkdownDocument::createFromString($t);
+$md->compile();
+echo $md->getHtml();
+
+echo "\nDone.\n";
+--EXPECT--
+<p>First line</p>
+
+<pre><code>My code
+Foo bar
+</code></pre>
+Done.
View
20 tests/pp_with_github_tags.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Compile-time options: check WITH_GITHUB_TAGS effect
+--SKIPIF--
+<?php
+if (!extension_loaded('discount'))
+ die('SKIP discount extension not loaded');
+--FILE--
+<?php
+$t = <<<EOD
+Test <_arghfoo_bar>
+EOD;
+
+$md = MarkdownDocument::createFromString($t);
+$md->compile();
+echo $md->getHtml();
+
+echo "\nDone.\n";
+--EXPECT--
+<p>Test <_arghfoo_bar></p>
+Done.
View
32 tests/set_reference_prefix_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+MarkdownDocument::setReferencePrefix basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('discount'))
+ die('SKIP discount extension not loaded');
+--FILE--
+<?php
+
+$t = <<<EOD
+I haz a footnote[^1]
+[^1]: yes?
+EOD;
+
+
+$md = MarkdownDocument::createFromString($t);
+$md->setReferencePrefix('foobar');
+$md->compile(MarkdownDocument::EXTRA_FOOTNOTE);
+echo $md->getHtml();
+
+echo "\nDone.\n";
+--EXPECT--
+<p>I haz a footnote<sup id="foobarref:1"><a href="#foobar:1" rel="footnote">1</a></sup></p>
+<div class="footnotes">
+<hr/>
+<ol>
+<li id="foobar:1">
+<p>yes?<a href="#foobarref:1" rev="footnote">&#8617;</a></p></li>
+</ol>
+</div>
+
+Done.
View
27 tests/set_reference_prefix_error.phpt
@@ -0,0 +1,27 @@
+--TEST--
+MarkdownDocument::setReferencePrefix: error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded('discount'))
+ die('SKIP discount extension not loaded');
+--FILE--
+<?php
+
+$md = MarkdownDocument::createFromString('');
+$md->setReferencePrefix();
+$md->setReferencePrefix(1, 2);
+$md->setReferencePrefix(fopen('php://memory', 'r+'));
+$md->compile(MarkdownDocument::EXTRA_FOOTNOTE);
+$md->setReferencePrefix('foobar');
+--EXPECTF--
+Warning: MarkdownDocument::setReferencePrefix() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: MarkdownDocument::setReferencePrefix() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: MarkdownDocument::setReferencePrefix() expects parameter 1 to be string, resource given in %s on line %d
+
+Fatal error: Uncaught exception 'LogicException' with message 'Invalid state: the markdown document has already been compiled' in %s:%d
+Stack trace:
+#0 %s(%d): MarkdownDocument->setReferencePrefix('foobar')
+#1 {main}
+ thrown in %s on line %d

No commit comments for this range

Something went wrong with that request. Please try again.