Function tpnote_lib::html::rewrite_links
source · pub fn rewrite_links(
html: String,
prepend_dirpath: &Path,
rewrite_ext: bool,
allowed_urls: Arc<RwLock<HashSet<PathBuf>>>
) -> StringExpand description
Helper function that scans the input html string and converts
all relative local HTML links to absolute links by prepending
prepend_dirpath. If prepend_dirpath is empty, no convertion is
perfomed. Local absolute links and external URLs always remain untouched.
If rewrite_ext is true and the link points to a known Tp-Note file
extension, then .html is appended to the converted link. The resulting
HTML string contains all rewritten links, whose targets are finally added
to the allowed_urls.