/** * Handle the filter. * * @param \Docit\Core\Document $document * @param array $config * @return void */ public function handle(Document $document, array $config) { $content = $document->getContent(); $pattern = '/<!---([\\w\\W]*?)-->/'; if (preg_match($pattern, $content, $matches) === 1) { // not really required when using html doc tags. But in case it's frontmatter, it should be removed $content = preg_replace($pattern, '', $content); $attributes = array_replace_recursive($document->getAttributes(), Yaml::parse($matches[1])); $document->setAttributes($attributes); } $document->setContent($content); }
public function __construct(Factory $docit, Filesystem $files, Project $project, Container $container) { ini_set('memory_limit', '2G'); $path = $project->path($project->config('phpdoc_hook_settings.path')); $pathName = 'phpdoc'; parent::__construct($docit, $files, $project, $container, $path, $pathName); $this->parser = new PhpdocParser(); $this->mergeAttributes($project->config('phpdoc_hook_settings')); $this->setPath($path); }
/** * Handle the filter. * * @param \Docit\Core\Document $document * @param array $config * @return void */ public function handle(Document $document, array $config) { $this->parsedown->setConfig($config); $document->setContent($this->parsedown->text($document->getContent())); }