Markdown URL

General TRichView support forum. Please post your questions here
Post Reply
pyoung@wddc.com
Posts: 4
Joined: Wed Mar 31, 2021 8:56 pm

Markdown URL

Post by pyoung@wddc.com »

Using LoadMarkdown to load an .md file.

Linked images are not working.

If turn on dloBasePathLinks, I get an error as it appear to be appending the base path to the URL.
If I disable dloBasePathLinks, I do not get an error but I only see little red squares.

If the file is opened in a markdown editor like Texts! the images appear correctly.

What am I doing wrong?

Thanks
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Markdown URL

Post by Sergey Tkachenko »

Are images on remote URLs?

By default, the components load images only from local files.
If you need to download images, you should do it in OnImportPicture event. It is called not only for Markdown import, but for import from all formats that may contain external images.

For example, you can use Indy's TidHttp to download from HTTP and HTTPS locations.

If you use RichViewActions, you do not need to write any code.
Place idHTTP1: TIdHTTP and RVAIndyDownloadInterface1: TRVAIndyDownloadInterface on a form, assign
RVAIndyDownloadInterface1.IdHTTP = idHTTP1.
RVAControlPanel1.DownloadInterface = RVAIndyDownloadInterface1.
To support HTTPS protocol, place IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL component on the form, assign it to idHTTP1.IOHandler property (probably, you also need to change IdSSLIOHandlerSocketOpenSSL1.SSLOptions.SSLVersions, because by default it includes only sslvTLSv1, but servers may use newer protocol versions).

Alternatively, you can use TclHTTP and TRVAClDownloadInterface components (from CleverComponents).

If you do not use RichViewActions, you can call IdHttp1.Get to download image, then RVGraphicHandler.LoadFromStream to load it (RVGraphicHandler is a global singleton class from RVGrHandler unit).
pyoung@wddc.com
Posts: 4
Joined: Wed Mar 31, 2021 8:56 pm

Re: Markdown URL

Post by pyoung@wddc.com »

Great, thanks, will give that a try.
Post Reply