UnityMarkdownViewer icon indicating copy to clipboard operation
UnityMarkdownViewer copied to clipboard

Bug: no way to set base URL for images etc.

Open hybridherbst opened this issue 3 years ago • 1 comments

When using UnityMarkdownViewer programmatically (e.g. downloading a .md file as text and then displaying it), images currently can't be properly resolved when the image URLs are relative to the markdown document location.

Would be great if there was a way to specify a base URL where relative URLs are then referred to (for example: a callback to decide for each URL what to do with it).

Example: download https://raw.githubusercontent.com/atteneder/glTFast/main/README.md via UnityWebRequest and display it by passing the text to a new MarkdownViewer. Expected: can attach a callback for URls or specify the base URL in another way so that relative image URLs work Actual: getting errors since the relative URLs can't be resolved properly

Right place for such a callback would probably be MarkdownHandleImages.RemapURL?

hybridherbst avatar Sep 15 '21 08:09 hybridherbst

Yes, the best place would probably be to set the root URL as a property of the HandlerImages object when the document is created and then update RemapURL() accordingly.

Note that URI's starting with / should be relative to the host as well where by default they are from the project directory.

gwaredd avatar Sep 16 '21 16:09 gwaredd