Skip to content

Commit

Permalink
v1.1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vaakash committed Aug 16, 2020
1 parent b7c8940 commit 0f5c0fe
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 11 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"require": {
"erusev/parsedown": "^1.7",
"symfony/yaml": "^5.1"
"symfony/yaml": "^5.1",
"erusev/parsedown-extra": "^0.8.1"
}
}
49 changes: 48 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions git-it-write.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );

Expand Down
9 changes: 5 additions & 4 deletions includes/parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
Expand All @@ -16,15 +16,16 @@ 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 ) );

if ( count( $parts ) < 3 ) {
return array(
'front_matter' => $this->default_front_matter,
'html' => parent::text( $text )
'markdown' => $text
);
}

Expand All @@ -35,7 +36,7 @@ public function text( $text ){

return array(
'front_matter' => $front_matter,
'html' => parent::text( $markdown )
'markdown' => $markdown
);

}
Expand Down
6 changes: 4 additions & 2 deletions includes/publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ];
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 0f5c0fe

Please sign in to comment.