ezhes/HTMLFastParse

Support for Img tags

Closed this issue · 4 comments

The library looks promising. However, I tested it with the <img> tags and it just failed. It returned empty results. Can you look into this please? @ezhes

The HTML code which I tested against is

NSString *tableTest = @" \
<html> \
<head> \
<title>Page Title</title> \
</head> \
<body> \
 \
<h1>This is a Heading</h1> \
<p>This is a paragraph.</p> \
<p>Edit the code in the window to the left, and click \"Run\" to view the result.</p> \
<img src=\"https://static.scientificamerican.com/sciam/cache/file/4E0744CD-793A-4EF8-B550B54F7F2C4406.jpg\" alt=\"Avatar\" style=\"width:200px\"> \
 \
</body> \
</html> \
 \
";
ezhes commented

Hi,

HTMLFastParse doesn't support images at the moment. I'm also not sure what the expected behavior would be since attributed strings must have the image embedded directly in them and so to correctly parse your example we'd need to hit the network which IMO is well out of scope of a parser.

Hi @ezhes ,

Yes, img src tags require a network call. I was wondering how Cocoamarkdown was able to do it. It would be really great if we could do it in this parser!

ezhes commented

I didn't know cocoamarkdown did it, that's pretty cool!

Unfortunately I don't think I'll be adding this for the time being since this library is heavily focused on parsing the HTML returned by Reddit rather than being a super flexible general purpose renderer. Since Reddit doesn't have img tags in their responses, HTMLFastParse chooses to ignore them for simplicity.

If you do end up adding this yourself (which, afaik, would be a very difficult project given you'd need to write a lot of code to handle network and image layout), I would absolutely consider any pull request you submit!

Yes I will give it a try for sure!