From 6c79e0c077971029343b2dff30017571ea118438 Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Thu, 2 Mar 2017 23:25:04 +0100 Subject: [PATCH] :arrow_up: :hammer: Upgrade Markdownify library. The current version 2.0.0 (alpha) throws deprecated warning with PHP7.1 and PHPUnit. Upgrade the HTML to Markdown converter for PHP to the current Markdownify 2.2.1. Used composer to manage this library. --- composer.json | 3 +- composer.lock | 58 +- include/markdown.php | 10 +- library/markdownify/TODO | 29 - library/markdownify/example.php | 51 - library/markdownify/markdownify.php | 1197 -------------- library/markdownify/markdownify_cli.php | 33 - library/markdownify/markdownify_extra.php | 489 ------ library/markdownify/parsehtml/parsehtml.php | 618 -------- vendor/composer/autoload_classmap.php | 9 +- vendor/composer/autoload_psr4.php | 2 + vendor/composer/autoload_static.php | 25 +- vendor/composer/installed.json | 58 + vendor/pixel418/markdownify/CHANGELOG.md | 76 + .../pixel418/markdownify/LICENSE | 0 vendor/pixel418/markdownify/README.md | 63 + vendor/pixel418/markdownify/composer.json | 38 + vendor/pixel418/markdownify/src/Converter.php | 1400 +++++++++++++++++ .../markdownify/src/ConverterExtra.php | 573 +++++++ vendor/pixel418/markdownify/src/Parser.php | 564 +++++++ 20 files changed, 2869 insertions(+), 2427 deletions(-) delete mode 100644 library/markdownify/TODO delete mode 100644 library/markdownify/example.php delete mode 100644 library/markdownify/markdownify.php delete mode 100755 library/markdownify/markdownify_cli.php delete mode 100644 library/markdownify/markdownify_extra.php delete mode 100644 library/markdownify/parsehtml/parsehtml.php create mode 100644 vendor/pixel418/markdownify/CHANGELOG.md rename library/markdownify/LICENSE_LGPL.txt => vendor/pixel418/markdownify/LICENSE (100%) create mode 100644 vendor/pixel418/markdownify/README.md create mode 100644 vendor/pixel418/markdownify/composer.json create mode 100644 vendor/pixel418/markdownify/src/Converter.php create mode 100644 vendor/pixel418/markdownify/src/ConverterExtra.php create mode 100644 vendor/pixel418/markdownify/src/Parser.php diff --git a/composer.json b/composer.json index d977987eb..b59c81bba 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "ext-xml" : "*", "ext-openssl" : "*", "sabre/dav" : "~3.2", - "michelf/php-markdown" : "^1.7" + "michelf/php-markdown" : "^1.7", + "pixel418/markdownify": "^2.2" }, "require-dev" : { "php" : ">=5.6", diff --git a/composer.lock b/composer.lock index cf348bdae..06fb17410 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "4b24468c1f8babe7c8804fba8ee602f7", + "content-hash": "c0cafbf9fd702be588f6b392b9742cb6", "packages": [ { "name": "michelf/php-markdown", @@ -57,6 +57,62 @@ ], "time": "2016-10-29T18:58:20+00:00" }, + { + "name": "pixel418/markdownify", + "version": "v2.2.1", + "source": { + "type": "git", + "url": "https://github.com/Elephant418/Markdownify.git", + "reference": "0160677f04c784550dd10fd72fdf3994967db848" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Elephant418/Markdownify/zipball/0160677f04c784550dd10fd72fdf3994967db848", + "reference": "0160677f04c784550dd10fd72fdf3994967db848", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8" + }, + "type": "lib", + "autoload": { + "psr-4": { + "Markdownify\\": "src", + "Test\\Markdownify\\": "test" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Peter Kruithof", + "email": "pkruithof@gmail.com", + "homepage": "http://pkruithof.tumblr.com/" + }, + { + "name": "Milian Wolff", + "email": "mail@milianw.de", + "homepage": "http://milianw.de" + }, + { + "name": "Thomas Zilliox", + "email": "hello@tzi.fr", + "homepage": "http://tzi.fr" + } + ], + "description": "The HTML to Markdown converter for PHP ", + "homepage": "https://github.com/elephant418/Markdownify", + "keywords": [ + "markdown", + "markdownify" + ], + "time": "2016-09-21T13:01:43+00:00" + }, { "name": "psr/log", "version": "1.0.2", diff --git a/include/markdown.php b/include/markdown.php index 43d973808..7e1f1c42c 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -5,12 +5,12 @@ */ use Michelf\MarkdownExtra; +use Markdownify\Converter; require_once("include/oembed.php"); require_once("include/event.php"); require_once("include/html2bbcode.php"); require_once("include/bbcode.php"); -require_once("library/markdownify/markdownify.php"); function get_bb_tag_pos($s, $name, $occurance = 1) { @@ -367,7 +367,6 @@ function bb2diaspora_itemwallwall(&$item,$uplink = false) { function bb2diaspora_itembody($item, $force_update = false, $have_channel = false, $uplink = false) { - if(! get_iconfig($item,'diaspora','fields')) { $force_update = true; } @@ -454,7 +453,7 @@ function bb2diaspora_itembody($item, $force_update = false, $have_channel = fals return html_entity_decode($body); } -function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { +function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) { // Re-enabling the converter again. // The bbcode parser now handles youtube-links (and the other stuff) correctly. @@ -496,11 +495,10 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { $Text = str_replace(array('<','>','&'),array('&_lt_;','&_gt_;','&_amp_;'),$Text); // Now convert HTML to Markdown - $md = new Markdownify(false, false, false); + $md = new Converter(Converter::LINK_AFTER_CONTENT, false, false); $Text = $md->parseString($Text); - // It also adds backslashes to our attempt at getting around the html entity preservation for some weird reason. $Text = str_replace(array('&\\_lt\\_;','&\\_gt\\_;','&\\_amp\\_;'),array('<','>','&'),$Text); @@ -522,7 +520,7 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { $Text = trim($Text); - call_hooks('bb2diaspora',$Text); + call_hooks('bb2diaspora', $Text); return $Text; } diff --git a/library/markdownify/TODO b/library/markdownify/TODO deleted file mode 100644 index 06ec8508b..000000000 --- a/library/markdownify/TODO +++ /dev/null @@ -1,29 +0,0 @@ -Markdownify -=========== -* handle non-markdownifiable lists (i.e. ``) -* organize methods better (i.e. flushlinebreaks & setlinebreaks close to each other) -* take a look at function names etc. -* is the new (in rev. 93) lastclosedtag property needed? -* word wrapping (some work is done but it's still very buggy) - - -Markdownify Extra -================= - -* handle table alignment with KEEP_HTML=false -* handle tables without headings when KEEP_HTML=false is set -* handle Markdown inside non-markdownable tags - - -Implementation Thoughts -======================= -* non-markdownifiable lists and markdown inside non-markdownable tags as well as the current - table implementation could be rewritten by using a rollback mechanism. - - example: - - - - we come to `