gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.26k stars 267 forks source link

Are local images supported? #46

Closed codebeauty closed 3 years ago

codebeauty commented 3 years ago

Great library. Before I want to dive deeper into it, one question. Do you support local images? I see your example with an remote image. Is it possible to link a local image? Maybe from the asset bundle?

Thank you for your work. ๐Ÿ‘

gonzalezreal commented 3 years ago

MarkdownUI can render local images, provided that they can be located inside the bundle using a URL. This means that the image cannot be inside an asset catalog, and that you will need to set the markdown base URL to the bundle's resource URL. For example:

Screenshot 2021-04-25 at 17 14 09
Markdown(
    #"""
    This is a local image:

    ![Dog](dog.jpg)
    """#
)
.markdownBaseURL(Bundle.main.resourceURL)
markusmoenig commented 3 years ago

@gonzalezreal Also from my side thanks for MarkdownUI.

But could we not somehow define a sub folder of the base url for the images ? I want todo my dynamic help system with MarkdownUI and putting like 20-30 images into the main resource folder would mess up my project big time ... .

gonzalezreal commented 3 years ago

You could put the images in a separate bundle, and set the base URL to that bundle's resource URL. There is also some work in progress to support asset catalog images in #48. You may want to keep an eye on that.

codebeauty commented 3 years ago

Thank you for the clarification and keep up the great work ๐Ÿงก