Parse markdown to html

@param  string $markdown
@return string
189420
public function parse($markdown)
    {
        $document = $this->parser->parse($markdown);
        $html = $this->renderer->renderBlock($document);

        return $html;
    }
600437
def html_from_markdown(markdown):
    

    if login:
        r = requests.get(gh_url+"/rate_limit", auth=login.auth())
        if r.status_code >= 400:
            if r.status_code != 401:
                err = RequestError('Bad HTTP Status Code: %s' % r.status_code)
                raise err
            if verbose:
                sys.stderr.write('Unauthorized. Proceeding without login...\n')
            login.devalue()

    headers = {'content-type': 'text/plain', 'charset': 'utf-8'}

    r = requests.post(gh_url + "/markdown/raw", data=markdown.encode('utf-8'),
                      auth=login.auth(), headers=headers)
    if r.status_code >= 400 and r.status_code != 403:
            err = RequestError('Bad HTTP Status Code: %s' % r.status_code)
            raise err

    if verbose:
        sys.stderr.write("%s requests remaining, resets in %d minutes\n"
                         % rate_limit_info())
    return r.text
210157
public String markdownToHtml(String markdownString) {
		MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
		params.putSingle("md", markdownString);
		return getEntity(invokeGet("utils/md2html", params), String.class);
	}
216030
public static function htmlToDomDocument($html)
    {
        if (!$html) {
            $html = '';
        }

        // Transform multibyte entities which otherwise display incorrectly.
        $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');

        // Internal errors enabled as HTML5 not fully supported.
        libxml_use_internal_errors(true);

        // Instantiate new DOMDocument object, and then load in UTF-8 HTML.
        $dom = new DOMDocument();
        $dom->encoding = 'UTF-8';
        $dom->loadHTML("<div>$html</div>");

        return $dom;
    }
371885
private function getValidationData($markup)
    {
        $this->httpRequestParameters['body'] = $markup;

        $reponse = $this->httpClient->post(
            $this->configuration[self::ENDPOINT_CONFIG_KEY],
            $this->httpRequestParameters
        );
        $responseData = $reponse->getBody()->getContents();
        $validationData = json_decode($responseData, true);
        if ($validationData === null) {
            throw new Exception('Unable to parse W3C Markup Validation Service response.');
        }

        return $validationData;
    }
1058253
def markdown_helper(string)
      return unless string
      Kramdown::Document.new(string.to_s).to_html.html_safe
    end
35336
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;
    }
1085149
public String markdownToHtml(String markdownSource, LinkRenderer linkRenderer) {
        return markdownToHtml(markdownSource.toCharArray(), linkRenderer);
    }
767498
public function markup($data, $blacklisted = [])
    {
        //FILTER_SANITIZE_STRING
        //FILTER_SANITIZE_STRIPPED
        //\IS\HTML;
        //just form casting
        if (strtolower($verb) == 'request') {
            $verb = $this->getVerb();
        }
        $verb = strtolower($verb);
        $input = $this->$verb;
        //Undefined
        if (empty($name) || !isset($input) || !isset($input[$name])) {
            if (isset($default) && !empty($default)) {
                return $default;
            } else {
                return null; //nothing for that name;
            }
        }
        //uhhhnrrr...
        $string = $input[$name];

        //DOMDocument will screw up the encoding so we utf8 encode everything?
        $string = mb_convert_encoding($string, 'utf-8', mb_detect_encoding($string));
        $string = mb_convert_encoding($string, 'html-entities', 'utf-8');

        $doc = new \DOMDocument('1.0', 'UTF-8');
        //$doc->substituteEntities = TRUE;
        $doc->loadHTML($string, LIBXML_COMPACT | LIBXML_HTML_NOIMPLIED); //Load XML here, if you use loadHTML the string will be wrapped in HTML tags. Not good.
        $xpath = new \DOMXPath($doc);
        //@TODO remove tags that are not allowed;
        //Remove attributes
        $nodes = $xpath->query('//*[@style]');

        foreach ($nodes as $node):
            $node->removeAttribute('style'); //Removes the style attribute;
        endforeach;

        //We don't want to wrap in HTML tags
        $original = $xpath->query("body/*");
        if ($original->length > 0) {
            $string = '';
            foreach ($original as $node) {
                $string .= $doc->saveHTML($node);
            }
        }

        $filter = static::FILTER_SPECIAL_CHARS;
        $options = [
            "flags" => FILTER_FLAG_ENCODE_LOW, //or strip?
            "options" => []
        ];

        //if (is_array($html)) $str = strip_tags($str, implode('', $html));
        //elseif (preg_match('|<([a-z]+)>|i', $html)) $str = strip_tags($str, $html);
        //elseif ($html !== true) $str = strip_tags($str);
        //Some tags we really don't need
        $string = $this->filter($string, $filter, $options);

        return $string;
    }
1293365
def render_markdown(text, context=None):
    
    if context is None or not isinstance(context, dict):
        context = {}
    markdown_html = _transform_markdown_into_html(text)
    sanitised_markdown_html = _sanitise_markdown_html(markdown_html)
    return mark_safe(sanitised_markdown_html)
895868
public function setText($text, $markdown = false)
    {
        $this->data['text'] = $text;
        $this->markdownInText = $markdown;

        return $this;
    }
1123734
function getHtmlFromMarkedMarkdown(srcStr) {
	var result = parseSource(srcStr);
	var html = md.render(result);
	return html;
}
1304114
public function convert($markdown)
    {
        $root = new Container();

        $this->inlineParser = new InlineParser($this->links, $this->titles);
        $parser = $this->buildParserStack();

        $text = new Text($markdown);
        $this->prepare($text);

        $parser->parseBlock($text, $root);

        $this->inlineParser->parse();

        return $root;
    }
237942
function getMarkdown(): \Closure {
    return function($value, \Mustache_LambdaHelper $helper) {
      $args = $this->parseArguments($helper->render($value), 'markdown', ['flavor' => Markdown::$defaultFlavor]);
      return Markdown::process($args['markdown'], $args['flavor']);
    };
  }
49295
def parse_markdown_readme():
    
    # Attempt to run pandoc on markdown file
    import subprocess
    try:
        subprocess.call(
            ['pandoc', '-t', 'rst', '-o', 'README.rst', 'README.md']
        )
    except OSError:
        return LONG_DESCRIPTION

    # Attempt to load output
    try:
        readme = open(os.path.join(
            os.path.dirname(__file__),
            'README.rst'
        ))
    except IOError:
        return LONG_DESCRIPTION
    return readme.read()
978586
public static function convert($text)
    {
        static $parser;

        if (empty($parser)) {
            $parser = new MarkdownExtraExtended();
        }

        return $parser->transform($text);
    }
425312
function markdownFormat(str) {
  // if string...
  if(str && typeof str === 'string') {

    // process characters that do not render visibly in markdown
    str = str.replace(/\<(?!@)/g, '&lt;');
    str = str.split('').reverse().join('').replace(/\>(?!.*@\<)/g, ';tg&').split('').reverse().join('');

    return str;
  }

  // else return empty
  else {
    return '';
  }
}