PHP code example of philippoehrlein / inline-footnotes

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

    

philippoehrlein / inline-footnotes example snippets




eague\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\Footnote\FootnoteExtension;
use League\CommonMark\MarkdownConverter;
use PhilippOehrlein\InlineFootnotes\InlineFootnoteExtension;

// Create CommonMark environment
$environment = new Environment();

// Add standard CommonMark rules
$environment->addExtension(new CommonMarkCoreExtension());

// Add standard footnote extension (REQUIRED for rendering footnotes)
$environment->addExtension(new FootnoteExtension());

// Add inline footnotes extension (for preprocessing inline footnotes)
$environment->addExtension(new InlineFootnoteExtension());

// Create Markdown converter with the customized environment
$converter = new MarkdownConverter($environment);

// Convert Markdown with both types of footnotes
$markdown = "Here is a text with an inline footnote[^This is the footnote text].

And here is a text with a reference footnote[^1].

[^1]: This is the referenced footnote.";

$html = $converter->convert($markdown);

echo $html;