config = $config; $this->converter = new CommonMarkConverter(['daux' => $config]); } /** * @return string[] */ public function getExtensions() { return ['md', 'markdown']; } protected function doConversion($raw) { Daux::writeln("Running conversion", OutputInterface::VERBOSITY_VERBOSE); return $this->converter->convertToHtml($raw); } public function convert($raw, Content $node) { $this->config->setCurrentPage($node); if (!$this->config->canCache()) { return $this->doConversion($raw); } $cacheKey = $this->config->getCacheKey() . sha1($raw); $payload = Cache::get($cacheKey); if ($payload) { Daux::writeln("Using cached version", OutputInterface::VERBOSITY_VERBOSE); } else { Daux::writeln("Not found in the cache, generating...", OutputInterface::VERBOSITY_VERBOSE); $payload = $this->doConversion($raw); Cache::put($cacheKey, $payload); } return $payload; } }