PHP code example of jbzoo / markdown

1. Go to this page and download the library: Download jbzoo/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/ */

    

jbzoo / markdown example snippets


 declare(strict_types=1);

use JBZoo\Markdown\Table;

echo (new Table())
    ->addAutoIndex('Index', 999)
    ->setHeaders(['Header #1', 'Header #2'])
    ->setAlignments([Table::ALIGN_CENTER, Table::ALIGN_RIGHT])
    ->appendRow(['123', '456'])
    ->appendRows([
        ['789_1', '9871'],
        ['789_2', '']
    ])
    ->render();

 declare(strict_types=1);

use JBZoo\Markdown\Markdown;

// Page Navigation
echo Markdown::title('Page Name', 1);    // # Page Name\n
echo Markdown::title('Title', 2);        // ## Title\n
echo Markdown::title('Sub Title', 3);    // ### Sub Title\n

// Links
echo Markdown::url('Google', 'https://google.com');
// Output: [Google](https://google.com)

// Badges
echo Markdown::badge('Status', 'https://travis-ci.org/badge.svg', 'https://travis-ci.org/');
// Output: [![Status](https://travis-ci.org/badge.svg)](https://travis-ci.org/)

// Images
echo Markdown::image('https://example.com/logo.jpg', 'Logo');
// Output: ![Logo](https://example.com/logo.jpg)

// Blockquotes
echo Markdown::blockquote(['Quote Line 1', 'Quote Line 2', 'Quote Line 3']);
// Output:
// > Quote Line 1
// > Quote Line 2
// > Quote Line 3

// Spoiler (collapsible content)
echo Markdown::spoiler('Click to expand', 'Hidden content here');
// Output:
// <details>
//   <summary>Click to expand</summary>
//
//   Hidden content here
//
// </details>

// Code blocks
echo Markdown::code("\necho 'Hello World';\n", 'php');
// Output:
// 

 declare(strict_types=1);

use JBZoo\Markdown\Table;

// Basic table
$table = new Table();
$table->setHeaders(['Name', 'Age', 'City'])
      ->appendRow(['John', '25', 'New York'])
      ->appendRow(['Jane', '30', 'London']);

echo $table->render();

// Table with alignments
$table = new Table();
$table->setHeaders(['Left', 'Center', 'Right'])
      ->setAlignments([Table::ALIGN_LEFT, Table::ALIGN_CENTER, Table::ALIGN_RIGHT])
      ->appendRow(['Text', 'Text', 'Text']);

echo $table->render();

// Table with auto-indexing
$table = new Table();
$table->addAutoIndex('#', 1)
      ->setHeaders(['Item', 'Price'])
      ->appendRows([
          ['Apple', '$1.00'],
          ['Banana', '$0.50'],
          ['Orange', '$0.75']
      ]);

echo $table->render();