File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -1983,7 +1983,33 @@ function ($matches) {
1983
1983
$ f = $ this ->document ->createElement ('_script ' );
1984
1984
$ f ->setAttribute ('language ' , 'php ' );
1985
1985
$ f ->appendChild ($ c );
1986
- $ node = $ node ->parentNode ->replaceChild ($ f , $ node );
1986
+ $ node ->parentNode ->replaceChild ($ f , $ node );
1987
+
1988
+ //add previously trimmed space around text
1989
+ $ space = str_replace ($ trimmed , '| ' , $ text );
1990
+ $ explode = explode ('| ' , $ space );
1991
+ //space before text
1992
+ if ($ explode [0 ]) {
1993
+ $ s = $ this ->document ->createTextNode ($ explode [0 ]);
1994
+ $ f ->parentNode ->insertBefore ($ s , $ f );
1995
+ }
1996
+ //space after text
1997
+ if (isset ($ explode [1 ]) && $ explode [1 ]) {
1998
+ $ e = $ this ->document ->createTextNode ($ explode [1 ]);
1999
+ //php 8
2000
+ if (isset ($ f ->nextElementSibling ) && $ f ->nextElementSibling ) {
2001
+ //add before next element
2002
+ $ f ->parentNode ->insertBefore ($ e , $ f ->nextSibling );
2003
+ } else {
2004
+ if ($ f ->nextSibling ) {
2005
+ //add before next element
2006
+ $ f ->parentNode ->insertBefore ($ e , $ f ->nextSibling );
2007
+ } else {
2008
+ //add as last element
2009
+ $ f ->parentNode ->appendChild ($ e );
2010
+ }
2011
+ }
2012
+ }
1987
2013
}
1988
2014
//$node->parentNode->replaceChild($f, $node);
1989
2015
} else {
You can’t perform that action at this time.
0 commit comments