for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Kaloa\Renderer\Inigo\Handler;
use Kaloa\Renderer\Inigo\Handler\ProtoHandler;
use Kaloa\Renderer\Inigo\Parser;
/**
*
*/
final class FootnotesHandler extends ProtoHandler
{
* @var int
private $cnt;
* @var array
private $footnotes;
public function __construct()
$this->name = 'fn|fnt';
$this->type[0] = (Parser::TAG_INLINE | Parser::TAG_SINGLE);
$this->type[1] = (Parser::TAG_OUTLINE | Parser::TAG_CLEAR_CONTENT);
}
* @param array $data
* @return string
public function draw(array $data)
$ret = '';
if ($data['tag'] === 'fn' && $data['front']) {
$this->cnt++;
$ret = '[' . $this->cnt . ']';
} elseif ($data['tag'] === 'fnt' && !$data['front']) {
$this->footnotes[] = $data['content'];
return $ret;
public function initialize()
$this->cnt = 0;
$this->footnotes = array();
* @param string $s
public function postProcess($s, array $data)
if (($data['tag'] === 'fnt') && ($this->cnt > 0)) {
$ret .= '<ol>' . "\n";
foreach ($this->footnotes as $f) {
$ret .= '<li>' . $f . '</li>' . "\n";
$ret .= '</ol>';
return $s . $ret;