Please do NOT expect all Feature Requests to be actioned automatically. Describing your proposal here will ensure the development team are aware of it, and they will give it careful consideration.
  • Page:
  • 1

TOPIC:

Enabling Footnotes in Markdown 2 weeks 1 day ago #1

  • StuartG
  • StuartG's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 126
I have tried using the Markdown Footnote/Reference feature without success.

From my brief looking around to solve this problem it would seem that webtrees has not enabled the Footnote extension of the League CommonMark module. Is it possible to enable this extension please?

Thanks
Stuart
webtrees 2.0.16
⚶ Vesta Modules
PHP 7.3.7
Mysqli

Please Log in or Create an account to join the conversation.

Enabling Footnotes in Markdown 2 days 2 hours ago #2

  • StuartG
  • StuartG's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 126
Apparently there is no interest from others to enable this CommonMark extension. My son has kindly looked at what was required and has made the changes for me. It works to my total satisfaction. Here are the code changes:

In the file "app/Filter.php", add the following line near the top (in with the other use statements):
use League\CommonMark\Extension\Footnote\FootnoteExtension;

Then, in the markdown() function at the bottom, add the following line after the other environment lines:
        $environment->addExtension(new FootnoteExtension());

Lastly, add the following code to the configuration structure:
            'footnote' => [
                'ref_id_prefix'      => 'fnref' . rand() . ':',
                'footnote_id_prefix' => 'fn' . rand() . ':',
            ],

The entire function should look like:
    public static function markdown(string $text, Tree $tree): string
    {
        $environment = Environment::createCommonMarkEnvironment();
        $environment->addExtension(new ResponsiveTableExtension());
        $environment->addExtension(new CensusTableExtension());
        $environment->addExtension(new XrefExtension($tree));
        $environment->addExtension(new FootnoteExtension());

        $config = [
            'allow_unsafe_links' => false,
            'html_input'         => Environment::HTML_INPUT_ESCAPE,
            'footnote' => [
                'ref_id_prefix'      => 'fnref' . rand() . ':',
                'footnote_id_prefix' => 'fn' . rand() . ':',
            ],
        ];

        $converter = new CommonMarkConverter($config, $environment);

        return $converter->convertToHtml($text);
    }

As can be seen, it takes little to implement this extension and I would ask that these changes be included in the webtrees code whenever a new version is released. My son has implemented other changes for me, including the recent addition to how notes are displayed. See here for more info . The additions he has made are now part of a list of changes that has to be added to each new version of webtrees. This is becoming a little bit of a chore.

If these changes could be implemented I would be grateful. Thanks.
Stuart
webtrees 2.0.16
⚶ Vesta Modules
PHP 7.3.7
Mysqli

Please Log in or Create an account to join the conversation.

Enabling Footnotes in Markdown 1 day 20 hours ago #3

  • hermann
  • hermann's Avatar
  • Away
  • Senior Member
  • Senior Member
  • Posts: 321
Do you have a short example (or screenshot) of how you are using this new function?
webtrees 2.0.16 (all available custom modules installed, php 7.4.15, MySQL 5.6) @ ahnen.hartenthaler.eu/
and webtrees 1.7.18 (many custom modules) @ ahnen1.hartenthaler.eu/

Please Log in or Create an account to join the conversation.

Enabling Footnotes in Markdown 1 day 14 hours ago #4

  • StuartG
  • StuartG's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 126
I have only one small example of this code in action at this time. This example also includes the changes I have suggested to how Notes work when closed or expanded. I have been testing this small example on my test site and I have now made it available on my active site for you to see it in action. You can see it here .

This is an example of how to include an email received with attached files, in a Note and make it easy to understand and follow. I am slowly working on several other Notes and Shared notes, mainly incorporating places where families have been deeply involved in their establishment and development.

By expanding the Shared place data within the Summary and then the Note: you will also see how my changes to Notes work.
Stuart
webtrees 2.0.16
⚶ Vesta Modules
PHP 7.3.7
Mysqli

Please Log in or Create an account to join the conversation.

Enabling Footnotes in Markdown 17 hours 41 minutes ago #5

  • hermann
  • hermann's Avatar
  • Away
  • Senior Member
  • Senior Member
  • Posts: 321
Thanks for sharing this. It makes sense to me. Nice solution!
webtrees 2.0.16 (all available custom modules installed, php 7.4.15, MySQL 5.6) @ ahnen.hartenthaler.eu/
and webtrees 1.7.18 (many custom modules) @ ahnen1.hartenthaler.eu/

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum