vsch / flexmark-java

CommonMark/Markdown Java parser with source level AST. CommonMark 0.28, emulation of: pegdown, kramdown, markdown.pl, MultiMarkdown. With HTML to MD, MD to PDF, MD to DOCX conversion modules.
BSD 2-Clause "Simplified" License
2.21k stars 260 forks source link

Fix #548: Converting html images fails if the image refers to an emoji without a shortcut #562

Closed DamnedElric closed 1 year ago

DamnedElric commented 1 year ago

emojiReference.txt contains ~1000 emojis without shortcuts, but HtmlConverterCoreNodeRenderer.java made the incorrect assumption that every emoji had a shortcut, which broke converting certain <img> tags to Markdown.

PR includes a test case which illustrates the problem: the test will fail with an exception when the fix is not present.

DamnedElric commented 1 year ago

I have to say I'm very happy with the extensive test suites in flexmark! Great stuff!

vsch commented 1 year ago

@DamnedElric, thank you for the PR. I merged it, and added another test case with the full HTML source you had in issue #548.

```````````````````````````````` example Issue 548: 1
This is my test to a Facebook emoji:  
![text](https://static.xx.fbcdn.net/images/emoji.php/v9/t71/2/16/1f967.png)
.
<div>
<div>This is my test to a Facebook emoji:</div>
<div><img src="https://static.xx.fbcdn.net/images/emoji.php/v9/t71/2/16/1f967.png" alt="text" width="24" height="24"></div>
</div>
````````````````````````````````