PHP code example of fastvolt / markdown

1. Go to this page and download the library: Download fastvolt/markdown library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fastvolt / markdown example snippets


use FastVolt\Helper\Markdown;

$text = "## Hello, World";

// initialize markdown object
$markdown = new Markdown(); // or Markdown::new()

// set markdown content 
$markdown->setContent($text);

// compile as raw HTML
echo $markdown->toHtml();

$markdown = Markdown::new();

// set markdown file to parse 
$markdown->setFile('./sample.md');

// compile as raw HTML
echo $markdown->toHtml();


$markdown = Markdown::new()
    // set markdown file
    ->setFile(__DIR__ . '/blogPost.md')
    // set compilation directory 
    ->setCompileDir(__DIR__ . '/pages/')
    // compile as an html file 'newHTMLFile.html'
    ->toHtmlFile(filename: 'newHTMLFile');

if ($markdown) {
  echo "Compiled to ./pages/newHTMLFile.html";
}


$markdown = Markdown::new(
   sanitize: true
);

$markdown->setContent('<h1>Hello World</h1>');

echo $markdown->toHtml();

$markdown = Markdown::new();

$markdown->setInlineContent('_My name is **vincent**, the co-author of this blog_');

echo $markdown->toHtml();

$markdown = Markdown::new(sanitize: true)
    // s
    ->setInlineContent('_My name is **vincent**, the co-author of this blog_')
    ->setContent('Kindly follow me on my GitHub page via: [@vincent](https://github.com/oladoyinbov).')
    ->setContent('Here are the lists of my projects:')
    ->setContent('
- Dragon CMS
- Fastvolt Framework.
  + Fastvolt Router
  + Markdown Parser.
    ')
    // 
\n echo "Hi"; \n