Modify html file so relative-path images point to external server with absolute src urls.
Source:R/move_images.R
move_images.Rd
See ?wiseflow_images
for a user-friendlier version.
Value
Modified doc object, also overwritten on disk, with absolute remote src urls in place of relative ones.
Details
Example:
Assume html = "c:/path/doc.html" url_prefix = "https://example.org/~user/doc" remote_dir = "user@server.example.org:~/public_html/doc" and that doc.html contains
After move_images(html, url_prefix, remote_dir), doc.html contains the following, where HASH1 and HASH2 are strings derived from the html path and system time, to avoid image name clashes for images from unnamed or identically named chunks, or for multiple realizations of Rmd files using random variables.
img src="https://example.org/~user/doc/HASH1/HASH2/a.jpg"
img src="https://example.org/~user/doc/HASH1/HASH2/b/c.jpg"
img src="https://example.org/~user/doc/HASH1/HASH2/_fig/img-1.jpg"
and, if remote_dir is not NULL, server.example.org contains
~user/public_html/doc/HASH1/HASH2/a.jpg
~user/public_html/doc/HASH1/HASH2/b/c.jpg
~user/public_html/doc/HASH1/HASH2/_fig/img-1.jpg
If clean=TRUE, the directory c:/path/doc_files/* is recursively deleted. Set this to FALSE if you need to manually copy files instead of having move_images() call ssh and scp.
The xml_document is scanned for src urls that are relative, i.e. don't start with http, and are not data URIs, and those urls are replaced with absolute ones under url_prefix.
The src images will be copied using scp to remote_dir if that is set.
Otherwise you'll want to manually copy the local images to the remote server.
Note: Upgrading to OpenSSH_for_Windows_8.1p1, LibreSSL 2.9.2 fixed issues with GetConsoleMode on STD_INPUT_HANDLE failed with 6 as suggested here: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4540#note_196938343