Place Markdown parsing in a function

This commit is contained in:
manfromhuh 2022-07-17 17:27:08 -04:00
parent b4c852a3c1
commit d719bcf101

View File

@ -1,11 +1,15 @@
<?php <?php
#Markdown parser dependancy #Markdown parser dependancy
require ($_SERVER['DOCUMENT_ROOT'].'/common/vendor/autoload.php'); require ($_SERVER['DOCUMENT_ROOT'].'/common/vendor/autoload.php');
function read_md($md_path){
#Markdown parseing code. #Markdown parseing code.
$MD_Parser = new ParsedownExtra(); $MD_Parser = new ParsedownExtra();
$MD_Path = "article.md"; $MD_Path = $md_path;
$MD_File = fopen($MD_Path, "r") or die("File not found."); $MD_File = fopen($MD_Path, "r") or die("File not found.");
$MD_Text = fread($MD_File, filesize($MD_Path)); $MD_Text = fread($MD_File, filesize($MD_Path));
$MD_Parser->text($MD_Text);
fclose($MD_File);
}
echo "<article id=\"article\">\n" . /* Adds the option to change the font size of the article text. */ echo "<article id=\"article\">\n" . /* Adds the option to change the font size of the article text. */
"<div id=\"font_btns\"> "<div id=\"font_btns\">
Text Size: Text Size:
@ -24,8 +28,8 @@
<li><a href=\"article.md\" title=\"Download \">MD</a></li> <li><a href=\"article.md\" title=\"Download \">MD</a></li>
</nav> </nav>
". ".
$MD_Parser->text($MD_Text) . "\n</article>"; read_md("article.md") . "\n</article>";
fclose($MD_File);
echo "\n</div><!--End of print-content div-->\n"; echo "\n</div><!--End of print-content div-->\n";
echo("<nav class=\"jmenu\"><div class=\"pmenu\"><ul id=\"back_btn\"><li><a href='..'>Back</a></li></ul></div></nav>\n"); echo("<nav class=\"jmenu\"><div class=\"pmenu\"><ul id=\"back_btn\"><li><a href='..'>Back</a></li></ul></div></nav>\n");
if ($tag_data != NULL){ if ($tag_data != NULL){