diff --git a/composer.json b/composer.json index f5846f7..3ac37f9 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "require": { "erusev/parsedown": "^1.7", - "symfony/yaml": "^5.1" + "symfony/yaml": "^5.1", + "erusev/parsedown-extra": "^0.8.1" } } diff --git a/composer.lock b/composer.lock index bdfef4e..d4cc394 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0fdd968fab65e7cab4cf2a05e9032a77", + "content-hash": "8848a84c2703f2931adee8658e6b88bf", "packages": [ { "name": "erusev/parsedown", @@ -52,6 +52,53 @@ ], "time": "2019-12-30T22:54:17+00:00" }, + { + "name": "erusev/parsedown-extra", + "version": "0.8.1", + "source": { + "type": "git", + "url": "https://github.com/erusev/parsedown-extra.git", + "reference": "91ac3ff98f0cea243bdccc688df43810f044dcef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/91ac3ff98f0cea243bdccc688df43810f044dcef", + "reference": "91ac3ff98f0cea243bdccc688df43810f044dcef", + "shasum": "" + }, + "require": { + "erusev/parsedown": "^1.7.4" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35" + }, + "type": "library", + "autoload": { + "psr-0": { + "ParsedownExtra": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "description": "An extension of Parsedown that adds support for Markdown Extra.", + "homepage": "https://github.com/erusev/parsedown-extra", + "keywords": [ + "markdown", + "markdown extra", + "parsedown", + "parser" + ], + "time": "2019-12-30T23:20:37+00:00" + }, { "name": "symfony/deprecation-contracts", "version": "v2.1.3", diff --git a/git-it-write.php b/git-it-write.php index 9fa093c..6e457c0 100644 --- a/git-it-write.php +++ b/git-it-write.php @@ -5,10 +5,10 @@ Description: Publish markdown files present in a Github repository as posts to WordPress automatically Author: Aakash Chakravarthy Author URI: https://www.aakashweb.com/ -Version: 1.0.1 +Version: 1.1 */ -define( 'GIW_VERSION', '1.0.1' ); +define( 'GIW_VERSION', '1.1' ); define( 'GIW_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash define( 'GIW_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) ); diff --git a/includes/parsedown.php b/includes/parsedown.php index f3631b2..f482b84 100644 --- a/includes/parsedown.php +++ b/includes/parsedown.php @@ -4,7 +4,7 @@ use Symfony\Component\Yaml\Yaml; -class GIW_Parsedown extends Parsedown{ +class GIW_Parsedown extends ParsedownExtra{ public $default_front_matter = array( 'title' => '', @@ -16,7 +16,8 @@ class GIW_Parsedown extends Parsedown{ public $uploaded_images = array(); - public function text( $text ){ + // Parses the front matter and the markdown from the content + public function parse_content( $text ){ $pattern = '/^[\s\r\n]?---[\s\r\n]?$/sm'; $parts = preg_split( $pattern, PHP_EOL.ltrim( $text ) ); @@ -24,7 +25,7 @@ public function text( $text ){ if ( count( $parts ) < 3 ) { return array( 'front_matter' => $this->default_front_matter, - 'html' => parent::text( $text ) + 'markdown' => $text ); } @@ -35,7 +36,7 @@ public function text( $text ){ return array( 'front_matter' => $front_matter, - 'html' => parent::text( $markdown ) + 'markdown' => $markdown ); } diff --git a/includes/publisher.php b/includes/publisher.php index 9e77dac..8f8aa25 100644 --- a/includes/publisher.php +++ b/includes/publisher.php @@ -119,9 +119,11 @@ public function create_post( $post_id, $item_slug, $item_props, $parent ){ return false; } - $parsed_content = $this->parsedown->text( $item_content ); + $parsed_content = $this->parsedown->parse_content( $item_content ); + $front_matter = $parsed_content[ 'front_matter' ]; - $content = GIW_Utils::process_content_template( $this->content_template, $parsed_content[ 'html' ] ); + $html = $this->parsedown->text( $parsed_content[ 'markdown' ] ); + $content = GIW_Utils::process_content_template( $this->content_template, $html ); // Get post details $post_title = empty( $front_matter[ 'title' ] ) ? $item_slug : $front_matter[ 'title' ]; diff --git a/readme.txt b/readme.txt index 32a4e3c..b7844c7 100644 --- a/readme.txt +++ b/readme.txt @@ -8,7 +8,7 @@ License: GPLv2 or later Requires PHP: 5.3 Requires at least: 4.4 Tested up to: 5.5 -Stable tag: 1.0.1 +Stable tag: 1.1 Publish markdown files present in a Github repository as posts to WordPress automatically @@ -132,6 +132,9 @@ Yes, if you want to pull posts from the a folder in a repository then you can sp ## Changelog +### 1.1 +* New: Support for Parsedown extra + ### 1.0.1 * Fix: Webhook is changed to `POST` method. * Fix: Readme formatting.