Skip to content

unwrapNoscriptImages missing some images #15

@olivier-m

Description

@olivier-m

Hi !

the unwrapNoscriptImages() method of the parser uses the image in the noscript tag when there is an image just before it, which works well in that very case. But there is no fallback for when there's no such previous image.
I made my own pre parsing function to fix this behaviours and it seems to work quite well. The idea is to replace the noscript tag in the "else" case of "if prevElement != nil && ps.isSingleImage(prevElement)". Something like that:

} else {
  dom.ReplaceChild(noscript.Parent, dom.FirstElementChild(tmpBody), noscript)
}

You can test the difference on https://www.newyorker.com/magazine/2020/06/01/a-window-onto-an-american-nightmare where the cartoons are not visible.
Sorry for not submitting a PR, I can make one if that something you'd prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions