MDL-60239 libraries: patch Markdown for PHP7.2
authorMarina Glancy <marina@moodle.com>
Mon, 2 Oct 2017 07:15:36 +0000 (15:15 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Mon, 2 Oct 2017 07:32:11 +0000 (15:32 +0800)
lib/markdown/Markdown.php
lib/markdown/readme_moodle.txt
lib/tests/markdown_test.php

index c3eaf44..f885a3d 100644 (file)
@@ -1870,9 +1870,9 @@ class Markdown implements MarkdownInterface {
                        return;
                }
 
-               $this->utf8_strlen = create_function('$text', 'return preg_match_all(
-                       "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", 
-                       $text, $m);');
+               $this->utf8_strlen = function($text) {
+                       return preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
+               };
        }
 
        /**
index c99bd75..7dbd4cf 100644 (file)
@@ -5,6 +5,9 @@ Procedure:
 * copy the classes and readme file to lib/markdown/* , Note .inc files need not be copied.
 * update function markdown_to_html() in weblib.php if necessary,
   note that we require the php files manually for performance reasons
+* pull commits https://github.com/michelf/php-markdown/commit/0c1337a4d483b1e0b66bfdc3ffa644eafd40aa27
+  and https://github.com/michelf/php-markdown/commit/251ffcce7582d4b26936679e340abca973d55220
+  if they are not included in the next release (or remove this step)
 * run phpunit tests
 
 Petr Skoda
index 248e569..af4d282 100644 (file)
@@ -63,4 +63,10 @@ class core_markdown_testcase extends basic_testcase {
         $result = "<p>some <a href=\"http://example.com/\">example link</a></p>\n";
         $this->assertSame($result, markdown_to_html($text));
     }
+
+    public function test_tabs() {
+        $text = "a\tbb\tccc\tя\tюэ\t水\tabcd\tabcde\tabcdef";
+        $result = "<p>a   bb  ccc я   юэ  水   abcd    abcde   abcdef</p>\n";
+        $this->assertSame($result, markdown_to_html($text));
+    }
 }