@@ -50,11 +50,17 @@ export type IPatch = ParagraphPatch | FilePatch;
50
50
51
51
export type PatchDocumentOutputType = OutputType ;
52
52
53
+ export type PatchDocumentPatternOption = {
54
+ readonly start : string
55
+ readonly end : string
56
+ }
57
+
53
58
export type PatchDocumentOptions < T extends PatchDocumentOutputType = PatchDocumentOutputType > = {
54
59
readonly outputType : T ;
55
60
readonly data : InputDataType ;
56
61
readonly patches : Readonly < Record < string , IPatch > > ;
57
62
readonly keepOriginalStyles ?: boolean ;
63
+ readonly pattern ?: PatchDocumentPatternOption ;
58
64
} ;
59
65
60
66
const imageReplacer = new ImageReplacer ( ) ;
@@ -64,6 +70,7 @@ export const patchDocument = async <T extends PatchDocumentOutputType = PatchDoc
64
70
data,
65
71
patches,
66
72
keepOriginalStyles,
73
+ pattern
67
74
} : PatchDocumentOptions < T > ) : Promise < OutputByType [ T ] > => {
68
75
const zipContent = await JSZip . loadAsync ( data ) ;
69
76
const contexts = new Map < string , IContext > ( ) ;
@@ -133,7 +140,7 @@ export const patchDocument = async <T extends PatchDocumentOutputType = PatchDoc
133
140
contexts . set ( key , context ) ;
134
141
135
142
for ( const [ patchKey , patchValue ] of Object . entries ( patches ) ) {
136
- const patchText = `{{ ${ patchKey } } }` ;
143
+ const patchText = `${ pattern ?. start || '{{' } ${ patchKey } ${ pattern ?. end || '}}' } ` ;
137
144
// TODO: mutates json. Make it immutable
138
145
// We need to loop through to catch every occurrence of the patch text
139
146
// It is possible that the patch text is in the same run
0 commit comments