Skip to content

League\CommonMark extension for HTML diagrams and captions inspired by Markdig.

License

Notifications You must be signed in to change notification settings

JanStanleyWatt/commonmark-figure-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commonmark Figure Extension

League\CommonMark extension for HTML diagrams and captions inspired by Markdig.

Installation

$ composer require jsw/commonmark-figure-extension

Usage

  • Fence the top and bottom of the sentence you want to be a figure with ^ like a code block
  • Continued text in bottom fence becomes figure caption
  • Even if the number of upper and lower ^ is different, it will be processed normally
$environment = new Environment();
$environment->addExtension(new CommonMarkCoreExtension());
            ->addExtension(new FigureExtension());

$converter = new MarkdownConverter($environment);

$markdown =<<<EOL
^^^
![example-image](https://example.com/image.jpg)
^^^ This is caption for image
EOL;

// <figure><p><img src="https://example.com/image.jpg" alt="example-image" /></p>
// <figcaption>This is caption for image</figcaption></figure>
echo $converter->convert($markdown);

Contribution

  1. Fork it (https://github.com/JanStanleyWatt/commonmark-figure-extension)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Rebase your local changes against the master branch (if necessary)
  5. Run test suite with the composer test command and confirm that it passe
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request

License

Apache-v2