Easy Markdown Parser with some Extensions

v1.0.2 2025-01-26 19:29 UTC

This package is not auto-updated.

Last update: 2025-05-19 17:49:12 UTC


README

MDX

Infosophie Mdx is a small Markdown Parser based on the Markdown Parser erusev/parsedown by Emanuil Erusev (https://github.com/erusev/parsedown).

Functions

Quick Guide

  • Installation with Composer: require infosophie/mdx
  • Usage:

      # Use this if manually installed
      require('Mdx.php');
      # Use this installed with Composer
      require('vendor/autoload.php');
        
      use Infosophie\Mdx;
      # md-data is the path where the md files are stored, relative to the script's path
      $mdx = new Mdx('md-data');
      # if the 1st parameter is true or omitted, a default header and footer will be added
      $html = render Mdx(false);
        
      # $html will contain the parsed content in html format. You may echo it or use it otherwise.
      echo $html;
    

Extra Tags

Extra tags are wrapped into double curly brackets ({{lcub}}{{lcub}}extratag{{rcub}}{{rcub}}). The parameters(s) are separated with the pipe character (|). The first parameter of multiple parameters is the keyword that defines the function:

  • {{lcub}}{{lcub}}link|[path]|[text]{{rcub}}{{rcub}}: Insert a Link to an internal md document.
    • [path] denotes the path to the md-file, relative to the base path passed to the constructor of mdx
    • [text] is the linking text shown in the resulting html document. If is omitted, the first 1st-level heading of the linked document will be used.
  • {{lcub}}{{lcub}}ref|[path]|[text]}}: same es Link (see above) but the link will be wrapped like this: (s. Link-to-somewhere)
  • {{lcub}}{{lcub}}include|[path]}: the md file at [path] will be included at this position before the document is rendered. You can reuse contents without copying.
  • {{num}} =: Put an equal sign (=) behind the hashtags of a heading and it will be rendered as a dropdown. The dropped area will be everything until the next heding of the same or a higher level (or until the end of the document).