1. Go to this page and download the library: Download ancarda/gemtext-parser 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/ */
ancarda / gemtext-parser example snippets
$parser = new Ancarda\Gemini\Gemtext\Parser;
$encoder = new Ancarda\Gemini\Gemtext\Encoder\HTML;
$nodes = $parser->parse(explode("\n", $gemtext));
$html = implode("\n", iterator_to_array($encoder->encode($nodes)));
$transformer = new \Ancarda\Gemini\Gemtext\Util\SimpleTransformer;
echo $transformer->transform($gemText);
$reverse_paragraphs = new class {
public function __invoke(Generator $nodes): Generator
{
foreach ($nodes as $node) {
if ($node instanceof Paragraph) {
yield new Paragraph(strrev($node->getText()));
} else {
yield $node;
}
}
}
};