PHP code example of ckunkle / markdownwriter

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

    

ckunkle / markdownwriter example snippets



= new \MarkdownWriter\Writer();
$md->h1("Example Markdown")
->p("This class makes generating markdown using PHP quick and convenient")
->ol([
    "Here is",
    "An ordered list",
    "With",
    [
        "Nested",
        [
            "Sublists"
        ],
    ],
])
->blockQuote("View the API documentation below to learn more features");

$md->italic("test");

$md->bold("test");

$md->superscript("test");

$md->subscript("test");

$md->code("test");

$md->strikethrough("test");

$md->link("test", "http://example.com");

$md->image("test", "path/to/file.png");

$md->write("A string of text");
$md->write(" Another string of text");
echo($md);

$md->block("A string of text");
$md->block("Another string of text");
echo($md);

$md->p("A string of text");
$md->p("Another string of text");
echo($md);

$md->write("A string of text");
$md->nl();
$md->nl();
$md->write("Another string of text");
echo($md);

//or pass an integer for multiple newlines
$md->write("A string of text");
$md->nl(2);
$md->write("Another string of text");
echo($md);

$md->h1("Header");
echo($md);

$md->h2("Header");
echo($md);

$md->h3("Header");
echo($md);

$md->h4("Header");
echo($md);

$md->h5("Header");
echo($md);

$md->h6("Header");
echo($md);

$md->write("A string");
$md->hr();
$md->write("Another string");
echo($md);

$md->ulItem("Item1");
$md->ulItem("Item2", 1);
$md->ulItem("Item3", 2);
echo($md);

$md->olItem("Item1");
$md->olItem("Item2", 1);
$md->olItem("Item3", 2, "123");
echo($md);

$md->ul([
    "Item1",
    "Item2",
    "Item3",
    [
        "Subitems",
        [
            "SubSubItems..."
        ],
    ],
]);
echo($md);

$md->ol([
    "Item1",
    "Item2",
    "Item3",
    [
        "Subitems",
        [
            "SubSubItems..."
        ],
    ],
]);
echo($md);

$md->blockQuote("Pass a string for simple block quote...");
$md->blockQuote([
    "Or an array for",
    "a multiline block quote",
]);
$md->blockQuote(function($md) {
    $md->p("This blockquote uses a callback")
    ->p("This allows us to use the writer's functionality to create content")
    ->blockQuote([
        "including",
        "block quotes"
    ]);
});

$md->codeBlock("echo('This is a code block');");

    echo('This is a code block');
    

$md->table([
    ["col1", "col2", "col3"],
    ["val1", "val2", "val3"],
    ["val1", "val2", "val3"],
]);