@@ -133,42 +133,10 @@ protected function getFormattedTextBlock(DOMNode $node)
133133        $ text  = str_replace (['<em> ' , '</em> ' ], '* ' , $ text );
134134
135135        $ nodeLines  = explode ("\n" , $ text );
136-         $ lines      = [];
137- 
138-         foreach  ($ nodeLines  as  $ currentLine ) {
139-             $ currentLine  = trim ($ currentLine );
140-             if  ($ currentLine  === '' ) {
141-                 // The text contained a blank line. Respect this. 
142-                 $ lines [] = '' ;
143-                 continue ;
144-             }
145- 
146-             $ tempLine  = '' ;
147-             $ words     = explode ('  ' , $ currentLine );
148- 
149-             foreach  ($ words  as  $ word ) {
150-                 $ currentLength  = strlen ($ tempLine .$ word );
151-                 if  ($ currentLength  < 99 ) {
152-                     $ tempLine  .= $ word .'  ' ;
153-                     continue ;
154-                 }
155- 
156-                 if  ($ currentLength  === 99  || $ currentLength  === 100 ) {
157-                     // We are already at the edge, so we are done. 
158-                     $ lines []  = $ tempLine .$ word ;
159-                     $ tempLine  = '' ;
160-                 } else  {
161-                     $ lines []  = rtrim ($ tempLine );
162-                     $ tempLine  = $ word .'  ' ;
163-                 }
164-             }//end foreach 
165- 
166-             if  ($ tempLine  !== '' ) {
167-                 $ lines [] = rtrim ($ tempLine );
168-             }
169-         }//end foreach 
136+         $ nodeLines  = array_map ('trim ' , $ nodeLines );
137+         $ text       = implode (PHP_EOL , $ nodeLines );
170138
171-         return  implode ( PHP_EOL ,  $ lines  ).PHP_EOL .PHP_EOL ;
139+         return  wordwrap ( $ text ,  100 ,  PHP_EOL ).PHP_EOL .PHP_EOL ;
172140
173141    }//end getFormattedTextBlock() 
174142
0 commit comments