Transforms markdown syntax to HTML

@param string      $markdownText The markdown syntax text
@param null|string $parserName

@return string                   The HTML code

@throws \RuntimeException
165869
public function transform($markdownText, $parserName = null)
    {
        if (null === $parserName) {
            $parserName = 'default';
        }

        if (!isset($this->parsers[$parserName])) {
            throw new \RuntimeException(sprintf('Unknown parser selected ("%s"), available are: %s', $parserName, implode(', ', array_keys($this->parsers))));
        }

        $parser = $this->parsers[$parserName];

        return $parser->transformMarkdown($markdownText);
    }
948594
public function render($content, $data = [])
    {
        if (!$content) {
            return '';
        }

        $html = $this->renderTwig($content, $data);

        $html = Markdown::parseSafe($html);

        return $html;
    }
1173267
def markdown_to_html( content )    
    ## note: set to gfm (github-flavored markdown) by default
    ##   see http://kramdown.gettalong.org/parser/gfm.html
    kramdown_config = {
      'input'     => 'GFM',
      'hard_wrap' => false
    }

    puts "  Converting markdown-text (#{content.length} bytes) to HTML using kramdown library with #{kramdown_config.inspect}..."
    
    Kramdown::Document.new( content, kramdown_config ).to_html
  end
830001
public function getMarkdownParser()
	{
		if($this->_parser===null)
			$this->_parser=$this->createMarkdownParser();
		return $this->_parser;
	}
994397
public static function newDocumentXHTML($markup = null, $charset = null) 
    {
        $contentType = $charset
        ? ";charset=$charset"
        : '';
        return self::newDocument($markup, "application/xhtml+xml{$contentType}");
    }
481309
public static function processMarkdown($string, $block = true)
    {
        $page     = Grav::instance()['page'] ?? null;
        $defaults = Grav::instance()['config']->get('system.pages.markdown');

        // Initialize the preferred variant of Parsedown
        if ($defaults['extra']) {
            $parsedown = new ParsedownExtra($page, $defaults);
        } else {
            $parsedown = new Parsedown($page, $defaults);
        }

        if ($block) {
            $string = $parsedown->text($string);
        } else {
            $string = $parsedown->line($string);
        }

        return $string;
    }
737570
public function generate($markup, $options = array()) {
        // 1 - write the content to the temp file
        $tempPath = $this->tempDirectory . '/' . uniqid();
        $tempPathOut = $tempPath . '-output';

        if( $markup instanceof MarkupInterface ) {
            $content = $markup->getContent();
        } else {
            $content = $markup;
        }

        // Store the content to the proper file
        file_put_contents($tempPath, $content);

        // Start building the command line
        $arguments = array('rst2html');

        if( $this->templatePath !== null ) {
            $arguments []= '--template=' . $this->templatePath;
        }

        if( $this->syntaxHighlight !== null ) {
            $arguments []= '--syntax-highlight=' . $this->syntaxHighlight;
        }

        if( $this->noSourceLinks != false ) {
            $arguments []= '--no-source-link';
        }

        if( $this->quiet != false ) {
            $arguments []= '--quiet';
        }

        if( $this->noDebug != false ) {
            $arguments []= '--no-debug';
        }

        $arguments []= $tempPath;
        $arguments []= $tempPathOut;

        // Get the builder
        $builder = new ProcessBuilder($arguments);

        // Build the process
        $process = $builder->getProcess();
        $process->setTimeout(3600);

        // Execute
        $process->run();

        if (!$process->isSuccessful()) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return file_get_contents($tempPathOut);
    }
687089
def maybe_render_markdown(string: str) -> Any:
    """"""
    if is_ipython_interpreter():  # pragma: no cover
        from IPython.display import Markdown  # type: ignore # noqa: E501

        return Markdown(string)
    else:
        return string
1209446
protected function parse_markdown( $text ) {
		static $markdown = null;

		if ( null === $markdown ) {
			$markdown = new Parsedown();
		}

		return $markdown->text( $text );
	}
440606
public function parse($content)
    {
        $this->parser
            ->setSafeMode(config('markdown.safe-mode', false))
            ->setUrlsLinked(config('markdown.urls', true))
            ->setMarkupEscaped(config('markdown.markups', true));

        if (config('markdown.xss', true)) {
            $content = preg_replace('/(\[.*\])\(javascript:.*\)/', '$1(#)', $content);
        }

        return $this->parser->text($content);
    }
61020
private static function _parseRichText($titleDetailPart = null) {
		$value = new PHPExcel_RichText();

		foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
			if (isset($titleDetailElement->t)) {
				$objText = $value->createTextRun( (string) $titleDetailElement->t );
			}
			if (isset($titleDetailElement->rPr)) {
				if (isset($titleDetailElement->rPr->rFont["val"])) {
					$objText->getFont()->setName((string) $titleDetailElement->rPr->rFont["val"]);
				}

				$fontSize = (self::_getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
				if (!is_null($fontSize)) {
					$objText->getFont()->setSize(floor($fontSize / 100));
				}

				$fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string'));
				if (!is_null($fontColor)) {
					$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($fontColor) ) );
				}

				$bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean');
				if (!is_null($bold)) {
					$objText->getFont()->setBold($bold);
				}

				$italic = self::_getAttribute($titleDetailElement->rPr, 'i', 'boolean');
				if (!is_null($italic)) {
					$objText->getFont()->setItalic($italic);
				}

				$baseline = self::_getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
				if (!is_null($baseline)) {
					if ($baseline > 0) {
						$objText->getFont()->setSuperScript(true);
					} elseif($baseline < 0) {
						$objText->getFont()->setSubScript(true);
					}
				}

				$underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string'));
				if (!is_null($underscore)) {
					if ($underscore == 'sng') {
						$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
					} elseif($underscore == 'dbl') {
						$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
					} else {
						$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
					}
				}

				$strikethrough = (self::_getAttribute($titleDetailElement->rPr, 's', 'string'));
				if (!is_null($strikethrough)) {
					if ($strikethrough == 'noStrike') {
						$objText->getFont()->setStrikethrough(false);
					} else {
						$objText->getFont()->setStrikethrough(true);
					}
				}
			}
		}

		return $value;
	}
393865
protected function renderText($text)
	{
		if ($this->enableNewlines) {
			return preg_replace("/(  \n|\n)/", "\\\\\\\\\n", $this->escapeLatex($text[1]));
		} else {
			return parent::renderText($text);
		}
	}
99346
public static function formatText(string $text, Tree $tree): string
    {
        switch ($tree->getPreference('FORMAT_TEXT')) {
            case 'markdown':
                return '<div class="markdown" dir="auto">' . self::markdown($text, $tree) . '</div>';
            default:
                return '<div class="markdown" style="white-space: pre-wrap;" dir="auto">' . self::expandUrls($text, $tree) . '</div>';
        }
    }
1051286
def markdown(text):
    """"""
    text = gfm(text)
    text = markdown_lib.markdown(text)
    return text
468690
protected function render($markdown, $replacements) {
    $m = new \Mustache_Engine();
    try {
      return $m->render($markdown, $replacements);
    }
    catch (\Mustache_Exception $e) {
      throw new \Exception("Error in $this->name: " . $e->getMessage());
    }
  }
1348486
protected function _parseInclude() {
        $this->_content = preg_replace_callback('`' . $this->_openTag . $this->_name . preg_quote($this->markup['include'][0]) . $this->_spaceR . preg_quote($this->markup['include'][1]) . $this->_space . '=' . $this->_space . '"([A-Za-z0-9_\-\$/]+)"' . $this->_space . '((' . preg_quote($this->markup['include'][2]) . $this->_space . '=' . $this->_space . '"([0-9]*)"' . $this->_space . ')*)' . $this->_space . '/' . $this->_closeTag . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseIncludeCallback'], $this->_content);
        $this->_content = preg_replace_callback('`' . $this->_openTag . $this->_name . preg_quote($this->markup['include'][0]) . $this->_spaceR . preg_quote($this->markup['include'][1]) . $this->_space . '=' . $this->_space . '"([A-Za-z0-9_\-\$/]+)"' . $this->_space . preg_quote($this->markup['include'][3]) . $this->_space . '=' . $this->_space . '"' . preg_quote($this->markup['include'][4]) . '"' . $this->_space . '((' . preg_quote($this->markup['include'][2]) . $this->_space . '=' . $this->_space . '"([0-9]*)"' . $this->_space . ')*)' . $this->_space . '/' . $this->_closeTag . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseIncludeCompileCallback'], $this->_content);
    }
1183243
protected function toMarkdown($content)
    {
        $tmpfname = tempnam(sys_get_temp_dir(), 'fillet'); // good
        file_put_contents($tmpfname, $content);
        $cmd = $this->config['pandoc']['bin'] . ' --no-wrap -f html -t markdown ' . $tmpfname;
        $content = shell_exec($cmd);
        unlink($tmpfname);
        return $content;
    }