Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imageView fails #5

Closed
npetri13 opened this issue Oct 21, 2020 · 3 comments
Closed

imageView fails #5

npetri13 opened this issue Oct 21, 2020 · 3 comments

Comments

@npetri13
Copy link

Hello and thanks for ur great work!

I've run into one issue related to images. I've derived from ParmaRenderable as discribed as follows:

struct AlculateRender: ParmaRenderable {
  func imageView(with urlString: String) -> AnyView {
	AnyView(Text(urlString))
  }
}

and initialize Parma with it. But the imageView function never got executed. So started a bit of debugging and the Image ElementComposer never called the imageView function.

struct ImageElementComposer: BlockElementComposer {
    func view(in context: ComposingContext, render: ParmaRenderable) -> AnyView {
        guard let urlString = context.attributes["destination"] else {
            return AnyView(EmptyView())
        }
        return render.imageView(with: urlString)
    }
}

The guard statement fails and it returns the EmptyView. The context.attributes contains one key/value element = ["xml:space", "preserve"], which is weired.

I tried the following markdown:

![Image](http://url/a.png)

![Image][1]

[1]: http://url/b.jpg 

Before i start further debugging, i may ask if u have any idea about that.

Thanks in advance

@dasautoooo
Copy link
Owner

dasautoooo commented Oct 23, 2020

Hi,
Thank you for your feedback. The reason that the image composer failed to retrieve the destination is the image composer cannot process text inside it. To fix the problem, simply remove the text from the image notation.

![](http://url/a.png)

![][1]

[1]: http://url/b.jpg 

This is a very good issue, thank you so much. Gonna try to fix it, and hopefully, it will be fine in version 1.0.

@dasautoooo
Copy link
Owner

dasautoooo commented Oct 25, 2020

Hi @npetri13 ,

In the latest release (v0.2.0), Parma's ImageElementComposer can correctly process the alt text inside it and get the destination.

Thanks again!

@npetri13
Copy link
Author

Hi @dasautoooo ,

wow, awesome response time. It works, i was able to implement a customized renderer.

As u told before it works by leaving the description empty. I could have bet i tried this, obviously i didn't.

Have a nice day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants