PHP code example of xp-forge / markdown

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

    

xp-forge / markdown example snippets


use net\daringfireball\markdown\Markdown;

$engine= new Markdown();
$transformed= $engine->transform(
  'This is [Markdown](http://daringfireball.net/projects/markdown/) for **XP**'
);

use net\daringfireball\markdown\{Markdown, ToHtml};
use io\streams\TextReader;
use io\File;

$engine= new Markdown();

$tree= $engine->parse($markdown);
$tree= $engine->parse(new TextReader(new File('file.md')));

// ...work with tree...

$transformed= $tree->emit(new ToHtml());

use net\daringfireball\markdown\{ToHtml, URLs, Rewriting};

$emitter= new ToHtml(new URLs(Rewriting::absolute()
  ->links('/deref?url=%s')
  ->images('/proxy?url=&s')
  ->excluding(['localhost'])
));

$transformed= $engine->transform($markdown, [], $emitter);
$transformed= $engine->parse($markdown)->emit($emitter);