Skip to content

Commit

Permalink
fix: make image plugin aware of the token stream
Browse files Browse the repository at this point in the history
  • Loading branch information
brotheroftux committed Feb 4, 2025
1 parent 6f817c7 commit ee690da
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/transform/plugins/images/collect.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import MarkdownIt from 'markdown-it';
import {Token} from 'markdown-it';
import {relative} from 'path';

import {isLocalUrl} from '../../utils';
import {resolveRelativePath} from '../../utilsFS';
import imsize from '../imsize';
import {MarkdownItPluginOpts} from '../typings';

type Options = MarkdownItPluginOpts & {
destPath: string;
copyFile: (path: string, dest: string) => void;
singlePage: boolean;
tokenStream: Token[];
};

const collect = (input: string, options: Options) => {
const md = new MarkdownIt().use(imsize);
const {root, path, destPath = '', copyFile, singlePage, tokenStream} = options;

const {root, path, destPath = '', copyFile, singlePage} = options;
const tokens = md.parse(input, {});
let result = input;

tokens.forEach((token) => {
tokenStream.forEach((token) => {
if (token.type !== 'inline') {
return;
}
Expand Down

0 comments on commit ee690da

Please sign in to comment.