PHP code example of davidbadura / markdown-builder

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

    

davidbadura / markdown-builder example snippets


$builder = new MarkdownBuilder();

$builder
    ->h1('Markdown Builder')
    ->p('A simple helper class to create markdown.')
    ->h2('Install ' . $builder->inlineBold('this') . ' powerfull library')
    ->code("composer ilder->getMarkdown();

echo (new MarkdownBuilder())->h1('Hello World')->getMarkdown();

echo (new MarkdownBuilder())->h2('Hello second world')->getMarkdown();

echo (new MarkdownBuilder())->h3('My name is...')->getMarkdown();

echo (new MarkdownBuilder())->p('paragraph')->getMarkdown();

echo (new MarkdownBuilder())->blockquote("Foo\nBar\nBaz")->getMarkdown();

echo (new MarkdownBuilder())->bulletedList(['Foo', 'Bar', 'Baz'])->getMarkdown();

echo (new MarkdownBuilder())->numberedList(['Foo', 'Bar', 'Baz'])->getMarkdown();

echo (new MarkdownBuilder())->hr()->getMarkdown();

echo (new MarkdownBuilder())->code('$var = "test";', 'php')->getMarkdown();

    $var = "test";
    

echo (new MarkdownBuilder())->table(
    ['col0', 'col1'],
    [
        ['row01', 'row01'],
        ['row10', 'row11'],
    ],
    [Alignment::CENTER, Alignment::RIGHT]
)->getMarkdown();

echo (new MarkdownBuilder())->inlineBold('Hey!');

echo (new MarkdownBuilder())->inlineItalic('huhu');

echo (new MarkdownBuilder())->inlineCode('$var = "test";');

echo (new MarkdownBuilder())->inlineLink('http://google.de', 'Google', 'Title');

echo (new MarkdownBuilder())->inlineImg('cat.jpg', 'Cat', 'Title');

$builder = new MarkdownBuilder();
$builder->blockqoute(
    (string)$builder
      ->block()
      ->h1('Lists')
      ->bulletedList([
        'Foo',
        $builder->block()->numberedList(['A', 'B', 'C']),
        'Bar'
      ])
);
markdown
>  Lists
>  =====
>
>  * Foo
>  * 1. A
>    2. B
>    3. C
>  * Bar