import path from "path" ; import LocationUtils from "../../utils/location" ; import editHTMLElement from "./editHTMLElement" ; param { string } currentFile param { HTMLDom } $ function resolveImages ( currentFile , $ ) { const currentDirectory = path . dirname ( currentFile ) ; return editHTMLElement ( $ , "img" , ( $img ) => { let src = $img . attr ( "src" ) ; if ( src === null || src === undefined || LocationUtils . isExternal ( src ) || LocationUtils . isDataURI ( src ) ) { return ; } src = LocationUtils . toAbsolute ( src , currentDirectory , "." ) ; src = LocationUtils . relative ( currentDirectory , src ) ; $img . attr ( "src" , src ) ; } ) ; } export default resolveImages ;