@@ -45,7 +45,7 @@ private static void Generate(this OpenXmlElement xmlElement, WordprocessingDocum
4545 // avoid {{tag}} like <t>{</t><t>{</t>
4646 //AvoidSplitTagText(xmlElement);
4747 // avoid {{tag}} like <t>aa{</t><t>{</t> test in...
48- AvoidSplitTagText ( xmlElement , tags . Select ( o => "{{" + o . Key + "}}" ) ) ;
48+ AvoidSplitTagText ( xmlElement , GetReplaceKeys ( tags ) ) ;
4949
5050 //Tables
5151 var tables = xmlElement . Descendants < Table > ( ) . ToArray ( ) ;
@@ -149,7 +149,7 @@ private static void AvoidSplitTagText(OpenXmlElement xmlElement)
149149
150150 private static void AvoidSplitTagText ( OpenXmlElement xmlElement , IEnumerable < string > txt )
151151 {
152- foreach ( var paragraph in xmlElement . Elements < Paragraph > ( ) )
152+ foreach ( var paragraph in xmlElement . Descendants < Paragraph > ( ) )
153153 {
154154 foreach ( var continuousString in paragraph . GetContinuousString ( ) )
155155 {
@@ -161,6 +161,31 @@ private static void AvoidSplitTagText(OpenXmlElement xmlElement, IEnumerable<str
161161 }
162162 }
163163
164+ private static List < string > GetReplaceKeys ( Dictionary < string , object > tags )
165+ {
166+ var keys = new List < string > ( ) ;
167+ foreach ( var item in tags )
168+ {
169+ if ( item . Value . IsStrongTypeEnumerable ( ) )
170+ {
171+ foreach ( var item2 in ( IEnumerable ) item . Value )
172+ {
173+ if ( item2 is Dictionary < string , object > dic )
174+ {
175+ foreach ( var item3 in dic . Keys )
176+ keys . Add ( "{{" + item . Key + "." + item3 + "}}" ) ;
177+ }
178+ break ;
179+ }
180+ }
181+ else
182+ {
183+ keys . Add ( "{{" + item . Key + "}}" ) ;
184+ }
185+ }
186+ return keys ;
187+ }
188+
164189 private static void ReplaceText ( OpenXmlElement xmlElement , WordprocessingDocument docx , Dictionary < string , object > tags )
165190 {
166191 var paragraphs = xmlElement . Descendants < Paragraph > ( ) . ToArray ( ) ;
0 commit comments