@it-service-npm/remark-relative-url-adjustment
v1.1.1
Published
The Remark plugin streamlines URL adjustments in Markdown files, ensuring links remain accurate even after file relocations or inclusions
Maintainers
Readme
@it-service-npm/remark-relative-url-adjustment Remark plugin
The Remark plugin streamlines URL adjustments in Markdown files, ensuring links remain accurate even after file relocations or inclusions.
Images and links within the markdown file will have their paths adjusted to be relative to the new document location.
When processor.data().filePathChanges is set,
this plugin adjusts all relative URLs
for images, definitions, and links
to ensure they are accurate.
Contents
Install
npm install --save-dev @it-service-npm/remark-relative-url-adjustmentExamples
Updating relative url for links, images
Images and links within the markdown file will have their paths adjusted to be relative to the new document location.
When processor.data().filePathChanges is set,
this plugin adjusts all relative URLs
for images, definitions, and links
to ensure they are accurate.
import { remark } from 'remark';
import * as vFile from 'to-vfile';
import {
remarkRelativeUrlsAdjustment
} from '@it-service-npm/remark-relative-url-adjustment';
import type { VFile } from 'vfile';
export async function remarkDirectiveUsingExample(
filePath: string
): Promise<VFile> {
return remark()
.data({
filePathChanges: {
sourcePath: './subfolder1/main.md',
destinationPath: './main.md'
}
})
.use(remarkRelativeUrlsAdjustment)
.process(await vFile.read(filePath));
};
Source file:
main.md:
Hello. I am the included. Test image:



Remark output:
Hello. I am the included. Test image:



API
Please, read the API reference.
