erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.69k stars 1.12k forks source link

How to implement a <figure> block #812

Open nvayalil opened 3 years ago

nvayalil commented 3 years ago

Hi, I wish to have a HTML 5

block with markdown, for example,

 <figure>
  <img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
  <figcaption>Fig.1 - Trulli, Puglia, Italy.</figcaption>
</figure> 

Is there a implementation for this? If not, please provide some helps.

taufik-nurrohman commented 3 years ago

It is possible via extension.

nvayalil commented 3 years ago

I checked the wiki, but no examples for how to add new tags like the above. Probably, I need to follow "Add Multi-Line Element" in the wiki. But where I add this extension when I am using a framework such as Laravel?

taufik-nurrohman commented 3 years ago

With the extension you could simply write a regular image syntax with a paragraph below it indented by a space, and it will becomes a <figure> element automatically:

![alt text](image-url.jpg) {style="width:100%"}
 This is an image caption.
taufik-nurrohman commented 3 years ago

But where I add this extension when I am using a framework such as Laravel?

Using composer require taufik-nurrohman/parsedown-extra-plugin, and do something like echo app(ParsedownExtraPlugin::class)->text('asdf')

?

nvayalil commented 3 years ago

Sorry for the delay, but my aim to use alt text as caption as well, In this case, should I override the parent inlineImage or create a new blockImage function?