Skip to content

Commit ee690da

Browse files
committed
fix: make image plugin aware of the token stream
1 parent 6f817c7 commit ee690da

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/transform/plugins/images/collect.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
import MarkdownIt from 'markdown-it';
1+
import {Token} from 'markdown-it';
22
import {relative} from 'path';
33

44
import {isLocalUrl} from '../../utils';
55
import {resolveRelativePath} from '../../utilsFS';
6-
import imsize from '../imsize';
76
import {MarkdownItPluginOpts} from '../typings';
87

98
type Options = MarkdownItPluginOpts & {
109
destPath: string;
1110
copyFile: (path: string, dest: string) => void;
1211
singlePage: boolean;
12+
tokenStream: Token[];
1313
};
1414

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

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

22-
tokens.forEach((token) => {
20+
tokenStream.forEach((token) => {
2321
if (token.type !== 'inline') {
2422
return;
2523
}

0 commit comments

Comments
 (0)