public static function getHtmlFromMDFile($mdFile, $search = array(), $replace = array(), $setBreaksEnabled = true, $useDocsDir = false)
 {
     global $REX;
     $curLocale = strtolower($REX['LANG']);
     if ($useDocsDir) {
         $rootPath = $REX['INCLUDE_PATH'] . '/addons/navigation_factory/docs/';
     } else {
         $rootPath = $REX['INCLUDE_PATH'] . '/addons/navigation_factory/';
     }
     if ($curLocale == 'de_de') {
         $file = $rootPath . $mdFile;
     } else {
         $file = $rootPath . 'lang/' . $curLocale . '/' . $mdFile;
     }
     if (file_exists($file)) {
         $md = file_get_contents($file);
         $md = str_replace($search, $replace, $md);
         $md = self::makeHeadlinePretty($md);
         $md = str_replace('```php', "```php\r\n<?php", $md);
         if (method_exists('Parsedown', 'set_breaks_enabled')) {
             $out = Parsedown::instance()->set_breaks_enabled($setBreaksEnabled)->parse($md);
         } elseif (method_exists('Parsedown', 'setBreaksEnabled')) {
             $out = Parsedown::instance()->setBreaksEnabled($setBreaksEnabled)->parse($md);
         } else {
             $out = Parsedown::instance()->parse($md);
         }
         $out = str_replace('&lt;?php<br />', "", $out);
         return $out;
     } else {
         return '[translate:' . $file . ']';
     }
 }
Esempio n. 2
0
File: help.php Progetto: web3d/tch
 /**
  * 默认动作
  */
 public function index()
 {
     require_once TCH_CORE_ROOT . '/vendor/Parsedown.php';
     $content = Parsedown::instance()->parse(file_get_contents(TCH_CORE_ROOT . '/template/admin/doc/readme.md'));
     $this->setVar('content', $content);
     $this->display();
 }
Esempio n. 3
0
 public function index()
 {
     $version = $this->request->post['version'];
     $lookup = $version;
     if ($version == '@version@') {
         $version = 'develop';
         $lookup = '';
     }
     if (substr($version, 0, 4) == 'dev-') {
         $version = preg_replace('/^dev-/i', '', $version);
         $lookup = '';
     }
     $url = $this->url . '/' . $version . '/' . $this->file;
     $changelog = RemoteResponse::get($url);
     if ($changelog) {
         $found = preg_match("/(#\\s" . $lookup . ".+?\\n.*?)(?=\\n{1,}#|\$)/uis", $changelog, $changelog);
         if ($found) {
             $changelog = \Parsedown::instance()->parse($changelog[0]);
             // auto-link issues
             $changelog = preg_replace("/#(\\d{1,})/uis", '<a target="_blank" href="' . $this->issues . '/$1">#$1</a>', $changelog);
             // auto-link contributors
             $changelog = preg_replace("/@([\\w]+)[^\\w]/uis", '<a target="_blank" href="' . $this->contrib . '/$1">@$1</a> ', $changelog);
             // add icons for platforms
             foreach ($this->platforms as $platform => $icon) {
                 $changelog = preg_replace('/(<a href="\\#' . $platform . '">)/uis', '$1<i class="fa fa-' . ($icon ?: $platform) . '"></i> ', $changelog);
             }
         } else {
             $changelog = 'No changelog for version <strong>' . $version . '</strong> was found.';
         }
     }
     $response = ['html' => $this->container['admin.theme']->render('@gantry-admin/ajax/changelog.html.twig', ['changelog' => $changelog, 'version' => $version, 'url' => $url, 'fullurl' => $this->fullurl . '/' . $this->file])];
     return new JsonResponse($response);
 }
Esempio n. 4
0
 public function getMod($slug)
 {
     $table_javascript = route('tdf_name', ['modmodpacks', '0', $slug]);
     $mod = Mod::where('slug', '=', $slug)->first();
     if (!$mod) {
         $redirect = new URLRedirect();
         $do_redirect = $redirect->getRedirect(Request::path());
         if ($do_redirect) {
             return Redirect::to($do_redirect->target, 301);
         }
         App::abort(404);
     }
     $can_edit = false;
     if (Auth::check()) {
         $maintainer = $mod->maintainers()->where('user_id', Auth::id())->first();
         if ($maintainer) {
             $can_edit = true;
         }
     }
     $authors = $mod->authors;
     $spotlights = $mod->youtubeVideos()->where('category_id', 2)->get();
     $tutorials = $mod->youtubeVideos()->where('category_id', 3)->get();
     $raw_links = ['website' => $mod->website, 'download_link' => $mod->download_link, 'donate_link' => $mod->donate_link, 'wiki_link' => $mod->wiki_link];
     $links = [];
     foreach ($raw_links as $index => $link) {
         if ($link != '') {
             $links["{$index}"] = $link;
         }
     }
     $markdown_html = Parsedown::instance()->setBreaksEnabled(true)->text(strip_tags($mod->description));
     $mod_description = str_replace('<table>', '<table class="table table-striped table-bordered">', $markdown_html);
     $title = $mod->name . ' - Mod - ' . $this->site_name;
     $meta_description = $mod->deck;
     return View::make('mods.detail', ['table_javascript' => $table_javascript, 'mod' => $mod, 'mod_description' => $mod_description, 'links' => $links, 'authors' => $authors, 'title' => $title, 'meta_description' => $meta_description, 'sticky_tabs' => true, 'spotlights' => $spotlights, 'tutorials' => $tutorials, 'can_edit' => $can_edit]);
 }
 public function testSetParsedown()
 {
     $renderer = new \DavidePastore\Slim\Views\MarkdownRenderer(__DIR__ . '/mocks/');
     $expected = \Parsedown::instance()->setMarkupEscaped(true);
     $renderer->setParsedown($expected);
     $this->assertEquals($expected, $renderer->getParsedown());
 }
Esempio n. 6
0
 /**
  * Field Render Function.
  *
  * Takes the vars and outputs the HTML for the field in the settings
  *
  * @since ReduxFramework 1.0.0
  */
 function render()
 {
     // If align value is not set, set it to false, the default
     if (!isset($this->field['align'])) {
         $this->field['align'] = false;
     }
     // Set align flag.
     $doAlign = $this->field['align'];
     // The following could needs to be omitted if align is true.
     // Only print it if allign is false.
     if (false == $doAlign) {
         echo '<style>#' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . ' {padding: 0;}</style>';
         echo '</td></tr></table><table class="form-table no-border redux-group-table redux-raw-table" style="margin-top: -20px;"><tbody><tr><td>';
     }
     echo '<fieldset id="' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . '" class="redux-field redux-container-' . $this->field['type'] . ' ' . $this->field['class'] . '" data-id="' . $this->field['id'] . '">';
     if (!empty($this->field['include']) && file_exists($this->field['include'])) {
         include $this->field['include'];
     }
     if (!empty($this->field['content']) && isset($this->field['content'])) {
         if (isset($this->field['markdown']) && $this->field['markdown'] == true) {
             require_once dirname(__FILE__) . "/parsedown.php";
             echo Parsedown::instance()->parse($this->field['content']);
         } else {
             echo $this->field['content'];
         }
     }
     do_action('redux-field-raw-' . $this->parent->args['opt_name'] . '-' . $this->field['id']);
     echo '</fieldset>';
     // Only print is align is false.
     if (false == $doAlign) {
         echo '</td></tr></table><table class="form-table no-border" style="margin-top: 0;"><tbody><tr style="border-bottom: 0;"><th></th><td>';
     }
 }
Esempio n. 7
0
 public function renderMarkdown($markdownText, $isEditMode)
 {
     $config = $this->context->getConfig();
     require_once __DIR__ . '/../lib/parsedown/Parsedown.php';
     $html = Parsedown::instance()->text($markdownText);
     // Support `TODO` and `FIXME`
     $html = preg_replace('/(^|\\W)(TODO|FIXME):?(\\W|$)/', '$1<span class="todo">$2</span>$3', $html);
     // Enhance links
     $openExternalLinksInNewTab = $config['openExternalLinksInNewTab'];
     $html = preg_replace_callback('|(<a href="([^"]+))"|', function ($match) use($isEditMode, $openExternalLinksInNewTab) {
         $url = $match[2];
         $isLocalLink = !strpos($url, '//');
         if ($isLocalLink && $isEditMode) {
             // Append `?edit` to local links (in order to stay in edit mode)
             return $match[1] . '?edit"';
         } else {
             if (!$isLocalLink && $openExternalLinksInNewTab) {
                 // Add `target="_blank"` to external links
                 return $match[0] . ' target="_blank"';
             } else {
                 return $match[0];
             }
         }
     }, $html);
     return $html;
 }
Esempio n. 8
0
 public function __construct($path, $outputName, FileReflector $reflector)
 {
     $this->path = $path;
     $this->outputName;
     $this->reflector = $reflector;
     $this->markdown = \Parsedown::instance();
 }
Esempio n. 9
0
function CMS_DATA()
{
    $cms_folder = 'weasel-cms/';
    require_once $cms_folder . 'parsedown.php';
    $_DATA = [];
    $_DATA['site'] = (include $cms_folder . 'config.php');
    $_DATA['site']['path'] = dirname($_SERVER['PHP_SELF']);
    unset($_DATA['site']['user']);
    unset($_DATA['site']['pass']);
    // Get all the existing data on to from the .dat file
    $db_data = file($cms_folder . $_DATA['site']['db'], FILE_IGNORE_NEW_LINES);
    $_DATA['pages'] = array();
    foreach ($db_data as $data_line) {
        $_DATA['pages'][] = json_decode($data_line, true);
    }
    // Order the data array by descending datetime, extract slugs and exclude inactive posts
    $db_slugs = array();
    $items_datetime = array();
    foreach ($_DATA['pages'] as $key => $row) {
        if (empty($row['active'])) {
            unset($_DATA['pages'][$key]);
        } else {
            $items_datetime[$key] = $row['timedate'];
            $db_slugs[] = $row['slug'];
            $_DATA['pages'][$key]['link'] = in_array('mod_rewrite', apache_get_modules()) ? dirname($_SERVER['PHP_SELF']) . '' . $row['slug'] . '.cms' : 'index.php?p=' . $row['slug'];
            unset($_DATA['pages'][$key]['order']);
            unset($_DATA['pages'][$key]['active']);
            unset($_DATA['pages'][$key]['timestamp']);
            $_DATA['pages'][$key]['timedate'] = date('Y.m.j H:i', $_DATA['pages'][$key]['timedate']);
            $_DATA['pages'][$key]['tags'] = implode(', ', $_DATA['pages'][$key]['tags']);
            $_DATA['pages'][$key]['content'] = Parsedown::instance()->text($_DATA['pages'][$key]['content']);
        }
    }
    array_multisort($items_datetime, SORT_DESC, $_DATA['pages']);
    // Get the current page data
    $_DATA['page'] = $_DATA['pages'][0];
    $_DATA['is_page'] = false;
    if (!empty($_GET['p']) && in_array($_GET['p'], $db_slugs)) {
        foreach ($_DATA['pages'] as $db_element) {
            if ($_GET['p'] == $db_element['slug']) {
                $_DATA['page'] = $db_element;
                $_DATA['is_page'] = true;
                break;
            }
        }
    }
    // Navigation Menu output
    $_DATA['menu'] = '<ul>';
    foreach ($_DATA['pages'] as $_PAGEITEM) {
        $current = $_PAGEITEM['slug'] == $_DATA['page']['slug'] ? ' class="active"' : '';
        $_DATA['menu'] .= '<li' . $current . '>';
        $_DATA['menu'] .= '<a href="' . $_PAGEITEM['link'] . '" title="' . $_PAGEITEM['title'] . '">';
        $_DATA['menu'] .= $_PAGEITEM['title'] . '</a>';
        $_DATA['menu'] .= '</li>';
    }
    $_DATA['menu'] .= '</ul>';
    // Returns the parsed data
    return $_DATA;
}
Esempio n. 10
0
 public function setTemplateVars()
 {
     $md = Parsedown::instance();
     $content = $md->parse(file_get_contents(realpath(dirname(__FILE__) . '/../../') . "/lib/view/help.txt"));
     $content = str_replace('${basepath}', INIT::$BASE_URL, $content);
     $this->template->content = $content;
     $this->template->basepath = INIT::$BASE_URL;
 }
Esempio n. 11
0
 /**
  * Markdown filter.
  *
  * Example usage inside template would be:
  *
  * ```
  * <div class="long_description">
  *     <xsl:value-of
  *         select="php:function('phpDocumentor\Plugin\Core\Xslt\Extension::markdown',
  *             string(docblock/long-description))"
  *         disable-output-escaping="yes" />
  * </div>
  * ```
  *
  * @param string $text
  *
  * @return string
  */
 public static function markdown($text)
 {
     if (!is_string($text)) {
         return $text;
     }
     $markdown = \Parsedown::instance();
     return $markdown->parse($text);
 }
Esempio n. 12
0
 public static function parse_md($text)
 {
     if (!class_exists('Parsedown')) {
         $path = VP_FileSystem::instance()->resolve_path('includes', 'parsedown');
         require $path;
     }
     return Parsedown::instance()->parse($text);
 }
Esempio n. 13
0
 /**
  * Updates the text of a LiveUpdate, and also sets the updatedAt field and the markdown representation of that update.
  *
  * @param $updateInput
  */
 public function setUpdate($updateInput)
 {
     $this->updatedAt = Carbon::now();
     $this->update = $updateInput;
     $this->parseIntegrations();
     $this->update = (new AcronymService())->parseAndExpand($this->update);
     $this->updateMd = \Parsedown::instance()->text($this->update);
 }
Esempio n. 14
0
 private function parseContent($filePath)
 {
     $content = "";
     if (file_exists($filePath)) {
         $fileContent = file_get_contents($filePath);
         $content = Parsedown::instance()->text($fileContent);
     }
     return $content;
 }
Esempio n. 15
0
 private function buildPost($post)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . "/app/core/Parsedown.php";
     $buildarr = array();
     // Get the whole post
     $blog_content = Parsedown::instance()->parse(join('', array_slice($post, 0)));
     $buildarr = array("content" => $blog_content);
     return $buildarr;
 }
Esempio n. 16
0
 /**
  * @dataProvider data
  */
 function test_($filename)
 {
     $markdown = file_get_contents($this->dataDir . $filename . '.md');
     $expectedMarkup = file_get_contents($this->dataDir . $filename . '.html');
     $expectedMarkup = str_replace("\r\n", "\n", $expectedMarkup);
     $expectedMarkup = str_replace("\r", "\n", $expectedMarkup);
     $actualMarkup = Parsedown::instance()->text($markdown);
     $this->assertEquals($expectedMarkup, $actualMarkup);
 }
Esempio n. 17
0
 /**
  * @dataProvider provider
  */
 function test_($filename)
 {
     $path = $this->get_data_path();
     $markdown = file_get_contents($path . $filename . '.md');
     $expected_markup = file_get_contents($path . $filename . '.html');
     $expected_markup = str_replace("\r\n", "\n", $expected_markup);
     $expected_markup = str_replace("\r", "\n", $expected_markup);
     $actual_markup = Parsedown::instance()->parse($markdown);
     $this->assertEquals($expected_markup, $actual_markup);
 }
Esempio n. 18
0
 public function __construct(Data $package, $package_type = null)
 {
     $data = new Data($package->blueprints()->toArray());
     parent::__construct($data, $package_type);
     $this->settings = $package->toArray();
     $html_description = \Parsedown::instance()->line($this->description);
     $this->data->set('slug', $package->slug);
     $this->data->set('description_html', $html_description);
     $this->data->set('description_plain', strip_tags($html_description));
     $this->data->set('symlink', is_link(USER_DIR . $package_type . DS . $this->slug));
 }
Esempio n. 19
0
 protected static function boot()
 {
     static::creating(function (Content $model) {
         $model->user_id = \Auth::user()->id;
         $model->introduction === '' && ($model->introduction = str_limit($model->text_html, 200));
     });
     static::saving(function (Content $model) {
         $model->text_html = \Parsedown::instance()->parse($model->text);
     });
     parent::boot();
 }
Esempio n. 20
0
 public function hardware()
 {
     // load views
     require APP . 'view/_templates/header.php';
     $myfile = fopen(APP . 'view/intro/hardware.md', "r") or die("Unable to open file!");
     $mess = fread($myfile, filesize(APP . 'view/intro/hardware.md'));
     $info = Parsedown::instance()->text($mess);
     require APP . 'view/intro/hardware.php';
     require APP . 'view/_templates/middle.php';
     require APP . 'view/intro/hardware.php';
     require APP . 'view/_templates/footer.php';
 }
Esempio n. 21
0
 /**
  * @param Data $package
  * @param bool $package_type
  */
 public function __construct(Data $package, $package_type = false)
 {
     $this->data = $package;
     $this->blueprints = $this->data->blueprints();
     if ($package_type) {
         $html_description = \Parsedown::instance()->line($this->blueprints->get('description'));
         $this->blueprints->set('package_type', $package_type);
         $this->blueprints->set('description_html', $html_description);
         $this->blueprints->set('description_plain', strip_tags($html_description));
         $this->blueprints->set('symlink', is_link(USER_DIR . $package_type . DS . $this->blueprints->name));
     }
 }
 /**
  * Returns the description for the section
  *
  * @return string
  */
 public function getDescription()
 {
     $descriptionSections = array();
     foreach ($this->getCommentSections() as $commentSection) {
         // Anything that is not the section comment or modifiers comment
         // must be the description comment
         if ($commentSection != $this->getReferenceComment() && $commentSection != $this->getTitleComment() && $commentSection != $this->getMarkupComment() && $commentSection != $this->getDeprecatedComment() && $commentSection != $this->getExperimentalComment() && $commentSection != $this->getCompatibilityComment() && $commentSection != $this->getModifiersComment() && $commentSection != $this->getParametersComment() && $commentSection != $this->getTemplateComment()) {
             $descriptionSections[] = $commentSection;
         }
     }
     $description = implode("\n\n", $descriptionSections);
     return Parsedown::instance()->text($description);
 }
Esempio n. 23
0
 /**
  * This function parse the given file into HTML and outputs a string
  * containing its content.
  *
  * @param int $index - index of parsed element
  * @return string parsed Markdown
  */
 public function parse($index)
 {
     try {
         if ($file = file_get_contents($this->config['path'])) {
             return Parsedown::instance()->text($file);
         } else {
             throw new Exception('Can not read ' . $this->config['path']);
         }
     } catch (Exception $e) {
         Logger::getInstance()->add(new Error('An unexpected error has occurred.', 'Remote::parse("' . $this->config['path'] . '")', $e->getMessage()));
         return '';
     }
 }
Esempio n. 24
0
 public static function parse_file($file, $template)
 {
     $m = new Mustache_Engine();
     $page = new FrontMatter($file);
     $title = $page->fetch('title');
     $content = $page->fetch('content');
     #$content = htmlspecialchars($content);
     $content = Parsedown::instance()->text($content);
     $date = $page->fetch('date');
     $author = $page->fetch('author');
     $description = $page->fetch('description') == '' ? '' : $page->fetch('description');
     $template = file_get_contents($template);
     $data = array('title' => $title, 'content' => $content, 'author' => $author, 'description' => $description, 'date' => $date);
     return $m->render($template, $data);
 }
Esempio n. 25
0
 /**
  * This function parse the given file into HTML and outputs a string
  * containing its content.
  *
  * @param int $index - index of parsed element
  * @return string parsed Markdown
  */
 public function parse($index)
 {
     try {
         if ($fh = fopen($this->config['path'], 'r')) {
             $content = Parsedown::instance()->text(fread($fh, filesize($this->config['path'])));
             fclose($fh);
             return $content;
         } else {
             throw new Exception('Can not open ' . $this->config['path']);
         }
     } catch (Exception $e) {
         Logger::getInstance()->add(new Error('An unexpected error has occurred.', 'Markdown::parse("' . $this->config['path'] . '")', $e->getMessage()));
         return '';
     }
 }
 public static function getHtmlFromMDFile($mdFile, $search = array(), $replace = array())
 {
     global $REX;
     $curLocale = strtolower($REX['LANG']);
     if ($curLocale == 'de_de') {
         $file = $REX['INCLUDE_PATH'] . '/addons/magnific_popup/' . $mdFile;
     } else {
         $file = $REX['INCLUDE_PATH'] . '/addons/magnific_popup/lang/' . $curLocale . '/' . $mdFile;
     }
     if (file_exists($file)) {
         $md = file_get_contents($file);
         $md = str_replace($search, $replace, $md);
         $md = self::makeHeadlinePretty($md);
         return Parsedown::instance()->parse($md);
     } else {
         return '[translate:' . $file . ']';
     }
 }
Esempio n. 27
0
 /**
  *
  */
 public function Mail()
 {
     if ($this->Session && $this->Permissions) {
         if ($this->Session['admin'] == 1 || $this->Permissions['mailinglist'] == 'Y') {
             $List = $this->input->post('List');
             // Switch statement
             switch ($List) {
                 case "Iedereen":
                     $Query = $this->Mailing->Mailing_Iedereen();
                     break;
                 case "VZW":
                     $Query = $this->Mailing->Mailing_VZW();
                     break;
                 case "Ouders":
                     $Query = $this->Mailing->Mailing_Ouders();
                     break;
                 case "Leiding":
                     $Query = $this->Mailing->Mailing_Leiding();
                     break;
                 case "Oudervergadering":
                     $Query = $this->Mailing->Mailing_Oudervergadering();
                     break;
                 default:
                     echo "Kan niet bepalen naar welke lijst hij de mails moet sturen ;-(";
                     die;
             }
             $text = $this->input->post('Message');
             // Mail message
             foreach ($Query as $Output) {
                 $this->email->set_mailtype("html");
                 $this->email->from('*****@*****.**', 'Mailing st-joris turnhout');
                 $this->email->to($Output->Email);
                 $this->email->subject($this->input->post('subject'));
                 $this->email->message(Parsedown::instance()->parse($text));
                 // Pasedown???? Bug possible!
                 $this->email->send();
                 $this->email->clear();
             }
             redirect('Mailing');
         }
     } else {
         redirect('Admin', 'refresh');
     }
 }
 /**
  * Parses the Markdown of the Page and renders the view.
  * Method is called by <code>dispatchAction()</code> in GenericPresenter.
  */
 protected function viewPage($request)
 {
     $model = new PageModel();
     $pageName = $request->getValue(CONTROLLER_PAGE_NAME);
     $genericResult = $model->viewPage($pageName);
     // Make sure we have no errors reading the file and then transform Markdown to HTML.
     if ($genericResult->getCode() == STATUS_OK) {
         //$html = Markdown($genericResult->getContent());
         $parser = Parsedown::instance();
         $parser->set_breaks_enabled(true);
         $html = $parser->parse($genericResult->getContent());
         // Create a new Result object to pass to OutputWrapper
         $obj["html"] = $html;
         $obj["markup"] = $genericResult->getContent();
         $genericResult = new GenericResult(STATUS_OK, $obj);
     }
     $view = new SimpleView($genericResult);
     $view->render();
 }
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  *
  * @throws Exception\MissingDependencyException if the Descriptor Builder is not present.
  *
  * @return void
  */
 public function register(Application $app)
 {
     if (!isset($app['descriptor.builder'])) {
         throw new Exception\MissingDependencyException('The builder object that is used to construct the ProjectDescriptor is missing');
     }
     $app['parser'] = $app->share(function ($app) {
         $parser = new Parser();
         $parser->setStopwatch($app['kernel.stopwatch']);
         $parser->setLogger($app['monolog']);
         return $parser;
     });
     $app['markdown'] = $app->share(function () {
         return \Parsedown::instance();
     });
     /** @var Translator $translator  */
     $translator = $app['translator'];
     $translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');
     $app['parser.files'] = new Collection();
     $app->command(new ParseCommand($app['descriptor.builder'], $app['parser'], $translator, $app['parser.files']));
 }
Esempio n. 30
0
 /**
  * Find all the param tags and if using special characters transform
  * using markdown otherwise just add a <p> tag to be consistent.
  *
  * @param \DOMDocument $xml Structure source to apply behaviour onto.
  *
  * @return \DOMDocument
  */
 public function process(\DOMDocument $xml)
 {
     $qry = '//tag[@name=\'' . $this->element_name . '\']/@description[. != ""]';
     $xpath = new \DOMXPath($xml);
     $nodes = $xpath->query($qry);
     /** @var \DOMElement $node */
     foreach ($nodes as $node) {
         // only transform using markdown if the text contains characters
         // other than word characters, whitespaces and punctuation characters.
         // This is because Markdown is a huge performance hit on the system
         if (!preg_match('/^[\\w|\\s|\\.|,|;|\\:|\\&|\\#]+$/', $node->nodeValue)) {
             $md = \Parsedown::instance();
             $node->nodeValue = $md->parse($node->nodeValue);
         } else {
             // markdown will always surround the element with a paragraph;
             // we do the same here to make it consistent
             $node->nodeValue = '&lt;p&gt;' . $node->nodeValue . '&lt;/p&gt;';
         }
     }
     return $xml;
 }