-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes an issue caused by iconv() not being defined in some environments * Fixes some deprecation issues and spacing * Improves header parsing by generating slugs the craft way * Improves dependency management
- Loading branch information
1 parent
21d615f
commit d0254c3
Showing
21 changed files
with
174 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
build | ||
vendor | ||
tests/report | ||
tests/unstable.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
<?php | ||
namespace SelvinOrtiz\Doxter; | ||
|
||
use SelvinOrtiz\Zit\IZit; | ||
use SelvinOrtiz\Zit\Zit; | ||
|
||
class Doxter | ||
class Doxter extends Zit | ||
{ | ||
public function parse($source, array $params = array()) | ||
public function init() | ||
{ | ||
$codeBlockSnippet = null; | ||
$addHeaderAnchors = true; | ||
$addHeaderAnchorsTo = array('h1', 'h2', 'h3'); | ||
$parseReferenceTags = true; | ||
$parseReferenceTagsRecursively = true; | ||
|
||
extract($params); | ||
// Define parser dependencies | ||
doxter()->stash('parser', new DoxterParser); | ||
doxter()->stash('parsedown', \Parsedown::instance()); | ||
doxter()->stash('headerParser', new HeaderParser); | ||
doxter()->stash('markdownParser', new MarkdownParser); | ||
doxter()->stash('referenceTagParser', new ReferenceTagParser); | ||
} | ||
|
||
// By parsing reference tags first, we have a chance to parse md within them | ||
if ($parseReferenceTags) | ||
protected function pop($id, $args=array() ) | ||
{ | ||
try | ||
{ | ||
$source = Di::getInstance()->referenceTagParser->parse($source, compact('parseReferenceTagsRecursively')); | ||
return parent::pop($id, $args); | ||
} | ||
|
||
$source = Di::getInstance()->markdownParser->parse($source, compact('codeBlockSnippet')); | ||
|
||
if ($addHeaderAnchors) | ||
catch (\Exception $e) | ||
{ | ||
$source = Di::getInstance()->headerParser->parse($source, compact('addHeaderAnchorsTo')); | ||
throw new Exception\MissingDependencyException($id); | ||
} | ||
} | ||
} | ||
|
||
|
||
return $source; | ||
/** | ||
* A way to grab the dependency container within the Doxter namespace | ||
*/ | ||
if (!function_exists('\\SelvinOrtiz\\Doxter\\doxter')) | ||
{ | ||
function doxter() | ||
{ | ||
return \SelvinOrtiz\Doxter\Doxter::getInstance(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
namespace SelvinOrtiz\Doxter; | ||
|
||
class DoxterParser extends Parser | ||
{ | ||
public function parse($source, array $params = array()) | ||
{ | ||
$codeBlockSnippet = null; | ||
$addHeaderAnchors = true; | ||
$addHeaderAnchorsTo = array('h1', 'h2', 'h3'); | ||
$parseReferenceTags = true; | ||
$parseReferenceTagsRecursively = true; | ||
|
||
extract($params); | ||
|
||
// By parsing reference tags first, we have a chance to parse md within them | ||
if ($parseReferenceTags) | ||
{ | ||
$source = doxter()->referenceTagParser->parse($source, compact('parseReferenceTagsRecursively')); | ||
} | ||
|
||
$source = doxter()->markdownParser->parse($source, compact('codeBlockSnippet')); | ||
|
||
if ($addHeaderAnchors) | ||
{ | ||
$source = doxter()->headerParser->parse($source, compact('addHeaderAnchorsTo')); | ||
} | ||
|
||
return $source; | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
library/src/SelvinOrtiz/Doxter/Exception/InvalidDependencyContainerException.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...ary/src/SelvinOrtiz/Doxter/BaseParser.php → library/src/SelvinOrtiz/Doxter/Parser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.