]> git.mxchange.org Git - friendica.git/blobdiff - library/markdown.php
Merge pull request #3874 from tobiasd/20171009-checkversion
[friendica.git] / library / markdown.php
index a8152c2ab61929b8e6b75fb45adf14ee0839991b..8def53fcbdaba4906f5ea5bf9403a97795079d29 100644 (file)
@@ -1,24 +1,38 @@
 <?php
-//# Install PSR-0-compatible class autoloader
-//spl_autoload_register(function($class){
-//     require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
-//});
 
-require_once("library/php-markdown/Michelf/MarkdownExtra.inc.php");
-# Get Markdown class
+/**
+ * @file library/markdown.php
+ *
+ * @brief Parser for Markdown files
+ */
+
+require_once "library/php-markdown/Michelf/MarkdownExtra.inc.php";
 use \Michelf\MarkdownExtra;
 
-function Markdown($text) {
+/**
+ * @brief This function parses a text using php-markdown library to render Markdown syntax to HTML
+ *
+ * This function is using the php-markdown library by Michel Fortin to parse a 
+ * string ($text).It returns the rendered HTML code from that text. The optional 
+ * $hardwrap parameter is used to switch between inserting hard breaks after
+ * every linefeed, which is required for Diaspora compatibility, or not. The
+ * later is used for parsing documentation and README.md files.
+ *
+ * @param string $text
+ * @param boolean $hardwrap
+ * @return string
+ */
 
+function Markdown($text, $hardwrap = true) {
        $a = get_app();
 
        $stamp1 = microtime(true);
 
-       # Read file and pass content through the Markdown parser
-       $html = MarkdownExtra::defaultTransform($text);
+       $MarkdownParser = new MarkdownExtra();
+       $MarkdownParser->hard_wrap = $hardwrap;
+       $html = $MarkdownParser->transform($text);
 
        $a->save_timestamp($stamp1, "parser");
 
        return $html;
 }
-?>