[Marked] If there is an image in the html
Used library: https://marked.js.org/
Emergency handling for cases where there is an image in the html tag during the mark down case.
(Unrefined code, if you have a good method, please share it in the comments)
Sample
Let's look at a sample case first.
The mark down is written as below, and when it is drawn, it should come out like the image below.
mark down
<table>
<tr>
<td>https://images.hive.blog/DQmWwFSXs6264npQxbEnBmYkjHCXDi8CGhUKY1DDJ8xBXYy/DSC_1973.JPG
<td>https://images.hive.blog/DQmQRExbzza6Mv2dbtDfETtKMEDH9ozy9zk8vEQuTWiC3Gk/DSC_1974.JPG
</tr>
</table>
markdown normal rendering
Below is the situation before adding the exception code. The image is being exposed as text.
A bug fix is urgently needed.
markdown error rendering
Resolution (Marked)
html(html) {
if (html.includes('http')) {
if (html.includes('.JPG')) {
html = html.replace(/http/gi, `
);
html = html.replace(/.JPG/gi, `.JPG"/>`);
} else if (html.includes('.jpg')) {
html = html.replace(/http/gi, `
);
html = html.replace(/.jpg/gi, `.jpg"/>`);
} else if (html.includes('.png')) {
html = html.replace(/http/gi, `
);
html = html.replace(/.png/gi, `.png"/>`);
} else if (html.includes('.jpeg')) {
html = html.replace(/http/gi, `
);
html = html.replace(/.jpeg/gi, `.jpeg"/>`);
}
}
return `${html}`;
},
The above code came out.
It's a very ignorant code, but I applied it because I didn't have time.
If you look at the contents, since html is included in the markdown, the html function is used, and the image part is surrounded by tags.
Once solved!.
web3.0 blogging service
Witness vote
Leave [Marked] If there is an image in the html to:
Read more #hive-152717 posts
Best Posts From suseona
We have not curated any of pishio's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From suseona
- Grid Bot Trading
- Write on blog.suseona.com and Get 100% Upvotes from @pishio!
- Security Update: Stronger Protection for Your Hive Keys
- AI Summary and Q&A Feature Now Available on blog.suseona.com
- AI Summary and Q&A Feature Now Available
- Suseona Weekly Contest – Week 1
- blog.suseona.com updates
- Hive Note MCP in the Claude Code
- Discovering Hive Note!
- The Rollercoaster of Trading: Chasing Profits in the Digital Wild West