0

i want to change markdown format of image to html.

But no success.

My html:

<label class="control-label abc-control-label"  id="image2">![ ](https://i.imgur.com/ZE8HMqh.png)</label> 
<br> 
<label class="control-label abc-control-label" id="image1">![ ](https://i.imgur.com/P92SWSj.png)</label>

my javascript:

$image_markdown = $(this).text() $image_format =
$image_markdown.match(/!\[.*?\]\((.*?)\)/) $new_image = '<img src="' +
$image_format + '" style="width:200px">' $(this).html($new_image);

My demo link : https://jsfiddle.net/bvotcode/6y0gupjq/8/

Thank you

ti saigon
  • 63
  • 4
  • 1
    I would suggest looking for a JavaScript library that can parse the markdown and generate the appropriate HTML, trying to do this yourself is re-inventing the wheel. – phuzi Mar 17 '23 at 14:59
  • 1
    Does this answer your question? [Javascript to convert Markdown/Textile to HTML (and, ideally, back to Markdown/Textile)](https://stackoverflow.com/questions/1319657/javascript-to-convert-markdown-textile-to-html-and-ideally-back-to-markdown-t) in particular this answer: https://stackoverflow.com/a/40066280/592958 – phuzi Mar 17 '23 at 14:59

0 Answers0