PHP code example of caco / un-markdown

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

    

caco / un-markdown example snippets


$markdownRemover = new MarkdownRemover();
echo $markdownRemover->strip('Hello **World**');

$markdownRemover = new MarkdownRemover('"Link prefix" ', '"Image prefix️" ', '"Comment prefix" ', '… ');
echo $markdownRemover->strip('Wow look at this link [example.com](https://example.com/) isn't it **awesome**?');

$classUnderTest = new MarkdownRemover();
$classUnderTest
    ->getReplacements()[8]
    ->setReplace(function ($matches) {
        return ReEmphasis::toBold($matches[2]);
    });
$classUnderTest
    ->getReplacements()[9]
    ->setReplace(function ($matches) {
        return ReEmphasis::toItalic($matches[2]);
    });
$classUnderTest
    ->getReplacements()[16]
    ->setReplace(function ($matches) {
        return ReEmphasis::toMonospaced($matches[1]);
    });
echo $classUnderTest->strip('**Test** *italic* `replacement`');