File tree 5 files changed +23
-7
lines changed
5 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -444,7 +444,7 @@ export class Sveltex<
444
444
// Apply the post-transformers
445
445
html = applyTransformations (
446
446
html ,
447
- frontmatter ?? { } ,
447
+ { ... ( frontmatter ?? { } ) , original : content } ,
448
448
markdownHandler . configuration . transformers . post ,
449
449
) ;
450
450
/* eslint-enable @typescript-eslint/no-unnecessary-condition */
Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ export class CodeHandler<B extends CodeBackend> extends Handler<
141
141
if ( transformers . post ) {
142
142
processed = applyTransformations (
143
143
processed ,
144
- mergedOpts ,
144
+ { ... mergedOpts , original : code } ,
145
145
transformers . post ,
146
146
) ;
147
147
}
Original file line number Diff line number Diff line change @@ -42,21 +42,21 @@ export class MathHandler<B extends MathBackend> extends Handler<
42
42
await this . handleCss ( ) ;
43
43
44
44
// Apply pre-transformers
45
- tex = applyTransformations (
45
+ const pretransformed = applyTransformations (
46
46
tex ,
47
47
{ inline : options ?. inline !== false } ,
48
48
this . _configuration . transformers . pre ,
49
49
) ;
50
50
51
51
const res = await super . process (
52
- tex ,
52
+ pretransformed ,
53
53
options ?? ( { } as MathProcessOptions < B > ) ,
54
54
) ;
55
55
56
56
// Apply post-transformers
57
57
res . processed = applyTransformations (
58
58
res . processed ,
59
- { inline : options ?. inline !== false } ,
59
+ { inline : options ?. inline !== false , original : tex } ,
60
60
this . _configuration . transformers . post ,
61
61
) ;
62
62
Original file line number Diff line number Diff line change @@ -261,7 +261,11 @@ export class VerbatimHandler<C extends CodeBackend> extends Handler<
261
261
typeAssert ( is < FullVerbEnvConfigNoop > ( config ) ) ;
262
262
}
263
263
264
- processed = applyTransformations ( processed , options , post ) ;
264
+ processed = applyTransformations (
265
+ processed ,
266
+ { ...options , original : innerContent } ,
267
+ post ,
268
+ ) ;
265
269
266
270
// If `component !== 'none'`, wrap the processed content in the
267
271
// output tag, so that `processed` now stores the _outer_ content.
Original file line number Diff line number Diff line change @@ -56,7 +56,19 @@ export interface Transformers<Options extends object> {
56
56
* - 2-tuple: `transformed = content.replaceAll(...transformation)`
57
57
* - Function: `transformed = transformation(content, opts)`
58
58
*/
59
- post ?: Transformer < Options > | Transformer < Options > [ ] | undefined | null ;
59
+ post ?:
60
+ | Transformer < Options & WithOriginal >
61
+ | Transformer < Options & WithOriginal > [ ]
62
+ | undefined
63
+ | null ;
64
+ }
65
+
66
+ interface WithOriginal {
67
+ /**
68
+ * The original content that was passed to the backend for processing. This
69
+ * is before pre-transformations were applied, too.
70
+ */
71
+ original : string ;
60
72
}
61
73
62
74
/**
You can’t perform that action at this time.
0 commit comments