Skip to content

Commit

Permalink
Added link before headers
Browse files Browse the repository at this point in the history
  • Loading branch information
maherelgamil authored Oct 25, 2016
1 parent 5184003 commit e63ac03
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/Laradown.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@

use ParsedownExtra;

class Laradown
class Laradown extends ParsedownExtra
{
/**
* @var
*/
protected $files;

/**
* @var ParsedownExtra
*/
protected $markdown;

/**
* Indicator for markdown collect block.
*
Expand All @@ -25,15 +20,28 @@ class Laradown

/**
* Laradown constructor.
*
* @param ParsedownExtra $markdown
*/
public function __construct(ParsedownExtra $markdown)
public function __construct()
{
$this->markdown = $markdown;
parent::__construct();

$this->files = app('files');
}

protected function element(array $Element)
{
$markup = '';

if(str_is('h*' , $Element['name'])){
$link = str_replace(' ', '-', strtolower($Element['text']));
$markup = '<a target="_self" href="#' .$link.'"><i class="fa fa-link"></i>Link</a>';
}

$markup .= parent::element($Element);

return $markup;
}

/**
* Convert markdown to html.
*
Expand All @@ -43,7 +51,7 @@ public function __construct(ParsedownExtra $markdown)
*/
public function convert($markdown)
{
return $this->markdown->text($markdown);
return $this->text($markdown);
}

/**
Expand Down

0 comments on commit e63ac03

Please sign in to comment.