@@ -25,6 +25,7 @@ import {userOptions, defaultOptions, OptionList} from '../util/Options.js';
2525import { MathDocument } from './MathDocument.js' ;
2626import { MathItem , Metrics } from './MathItem.js' ;
2727import { DOMAdaptor } from '../core/DOMAdaptor.js' ;
28+ import { FunctionList } from '../util/FunctionList.js' ;
2829
2930/*****************************************************************/
3031/*
@@ -47,6 +48,11 @@ export interface OutputJax<N, T, D> {
4748 */
4849 options : OptionList ;
4950
51+ /*
52+ * Lists of post-filters to call after typesetting the math
53+ */
54+ postFilters : FunctionList ;
55+
5056 /*
5157 * The DOM adaptor for managing HTML elements
5258 */
@@ -107,6 +113,7 @@ export abstract class AbstractOutputJax<N, T, D> implements OutputJax<N, T, D> {
107113 public static OPTIONS : OptionList = { } ;
108114
109115 public options : OptionList ;
116+ public postFilters : FunctionList ;
110117 public adaptor : DOMAdaptor < N , T , D > = null ; // set by the handler
111118
112119 /*
@@ -115,6 +122,7 @@ export abstract class AbstractOutputJax<N, T, D> implements OutputJax<N, T, D> {
115122 constructor ( options : OptionList = { } ) {
116123 let CLASS = this . constructor as typeof AbstractOutputJax ;
117124 this . options = userOptions ( defaultOptions ( { } , CLASS . OPTIONS ) , options ) ;
125+ this . postFilters = new FunctionList ( ) ;
118126 }
119127
120128 /*
@@ -154,4 +162,19 @@ export abstract class AbstractOutputJax<N, T, D> implements OutputJax<N, T, D> {
154162 return null as N ;
155163 }
156164
165+ /*
166+ * Execute a set of filters, passing them the MathItem and any needed data,
167+ * and return the (possibly modified) data
168+ *
169+ * @param {FunctionList } filters The list of functions to be performed
170+ * @param {MathItem } math The math item that is being processed
171+ * @param {any } data Whatever other data is needed
172+ * @return {any } The (possibly modified) data
173+ */
174+ protected executeFilters ( filters : FunctionList , math : MathItem < N , T , D > , data : any ) {
175+ let args = { math : math , data : data } ;
176+ filters . execute ( args ) ;
177+ return args . data ;
178+ }
179+
157180}
0 commit comments