feat: pass full markup source to preprocessors

pull/6169/head
Maxime LUCE 5 years ago
parent c7e820e08f
commit 25dedbe73e

@ -139,7 +139,7 @@ async function process_tag(
preprocessor: Preprocessor, preprocessor: Preprocessor,
source: Source source: Source
): Promise<SourceUpdate> { ): Promise<SourceUpdate> {
const { filename } = source; const { filename, source: markup } = source;
const tag_regex = const tag_regex =
tag_name === 'style' tag_name === 'style'
? /<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi ? /<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi
@ -160,6 +160,7 @@ async function process_tag(
const processed = await preprocessor({ const processed = await preprocessor({
content: content || '', content: content || '',
attributes: parse_tag_attributes(attributes || ''), attributes: parse_tag_attributes(attributes || ''),
markup,
filename filename
}); });

@ -22,6 +22,7 @@ export type MarkupPreprocessor = (options: {
export type Preprocessor = (options: { export type Preprocessor = (options: {
content: string; content: string;
attributes: Record<string, string | boolean>; attributes: Record<string, string | boolean>;
markup: string;
filename?: string; filename?: string;
}) => Processed | Promise<Processed>; }) => Processed | Promise<Processed>;

Loading…
Cancel
Save