PHP code example of stovak / fountain

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

    

stovak / fountain example snippets


    $input = "My fountain input text.";
    $screenplay = new \Fountain\Screenplay();
    $html = $screenplay->parse($input);

    $input = "My fountain input text.";
    // determine fountain elements
    $fountainElements = (new \Fountain\FountainParser())->parse($input);
    // parse fountain elements into html
    $html = (new \Fountain\FountainTags())->parse($fountainElements);

$eventDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
$eventDispatcher->addListener('fountain.render', function (\Fountain\Event\RenderEvent $event) {
    $event->setHtml(str_replace('horse', 'cat', $event->getHtml()));
});
// Create a new screenplay programmatically...
$it = new \Fountain\Screenplay($eventDispatcher);
$it->elements()->addElement(new NewLine());
$it->elements()->addElement($headExpected);
$it->elements()->addElement(new Action());
$it->elements()->last()->setText("John goes to see a man about a horse.");
$it->elements()->addElement(new Character());
$it->elements()->last()->setText("JOHN");
$it->elements()->addElement(new Parenthetical());
$it->elements()->last()->setText("(to himself)");
$it->elements()->addElement(new Dialogue());
$it->elements()->last()->setText("I wonder if he has any horses for sale.");
// Print that screenplay...
echo (string)$it;