|  | @@ 2131-2133 (lines=3) @@ | 
                                                            
                                    | 2128 |  | 			if ($chardata[$i]['type'] == 'NSM') { | 
                                                            
                                    | 2129 |  | 				if ($levcount) { | 
                                                            
                                    | 2130 |  | 					$chardata[$i]['type'] = $chardata[$i]['sor']; | 
                                                            
                                    | 2131 |  | 				} elseif ($i > 0) { | 
                                                            
                                    | 2132 |  | 					$chardata[$i]['type'] = $chardata[($i-1)]['type']; | 
                                                            
                                    | 2133 |  | 				} | 
                                                            
                                    | 2134 |  | 			} | 
                                                            
                                    | 2135 |  | 			if ($chardata[$i]['level'] != $prevlevel) { | 
                                                            
                                    | 2136 |  | 				$levcount = 0; | 
                                                                                
                                |  | @@ 2267-2270 (lines=4) @@ | 
                                                            
                                    | 2264 |  | 				 (($chardata[($i-1)]['type'] == 'R') OR ($chardata[($i-1)]['type'] == 'EN') OR ($chardata[($i-1)]['type'] == 'AN')) AND | 
                                                            
                                    | 2265 |  | 				 (($chardata[($i+1)]['type'] == 'R') OR ($chardata[($i+1)]['type'] == 'EN') OR ($chardata[($i+1)]['type'] == 'AN'))) { | 
                                                            
                                    | 2266 |  | 					$chardata[$i]['type'] = 'R'; | 
                                                            
                                    | 2267 |  | 				} elseif ($chardata[$i]['type'] == 'N') { | 
                                                            
                                    | 2268 |  | 					// N2. Any remaining neutrals take the embedding direction | 
                                                            
                                    | 2269 |  | 					$chardata[$i]['type'] = $chardata[$i]['sor']; | 
                                                            
                                    | 2270 |  | 				} | 
                                                            
                                    | 2271 |  | 			} elseif (($levcount == 0) AND (($i+1) < $numchars) AND ($chardata[($i+1)]['level'] == $prevlevel)) { | 
                                                            
                                    | 2272 |  | 				// first char | 
                                                            
                                    | 2273 |  | 				if (($chardata[$i]['type'] == 'N') AND ($chardata[$i]['sor'] == 'L') AND ($chardata[($i+1)]['type'] == 'L')) { | 
                                                                                
                                |  | @@ 2279-2282 (lines=4) @@ | 
                                                            
                                    | 2276 |  | 				 (($chardata[$i]['sor'] == 'R') OR ($chardata[$i]['sor'] == 'EN') OR ($chardata[$i]['sor'] == 'AN')) AND | 
                                                            
                                    | 2277 |  | 				 (($chardata[($i+1)]['type'] == 'R') OR ($chardata[($i+1)]['type'] == 'EN') OR ($chardata[($i+1)]['type'] == 'AN'))) { | 
                                                            
                                    | 2278 |  | 					$chardata[$i]['type'] = 'R'; | 
                                                            
                                    | 2279 |  | 				} elseif ($chardata[$i]['type'] == 'N') { | 
                                                            
                                    | 2280 |  | 					// N2. Any remaining neutrals take the embedding direction | 
                                                            
                                    | 2281 |  | 					$chardata[$i]['type'] = $chardata[$i]['sor']; | 
                                                            
                                    | 2282 |  | 				} | 
                                                            
                                    | 2283 |  | 			} elseif (($levcount > 0) AND ((($i+1) == $numchars) OR (($i+1) < $numchars) AND ($chardata[($i+1)]['level'] != $prevlevel))) { | 
                                                            
                                    | 2284 |  | 				//last char | 
                                                            
                                    | 2285 |  | 				if (($chardata[$i]['type'] == 'N') AND ($chardata[($i-1)]['type'] == 'L') AND ($chardata[$i]['eor'] == 'L')) { | 
                                                                                
                                |  | @@ 2291-2294 (lines=4) @@ | 
                                                            
                                    | 2288 |  | 				 (($chardata[($i-1)]['type'] == 'R') OR ($chardata[($i-1)]['type'] == 'EN') OR ($chardata[($i-1)]['type'] == 'AN')) AND | 
                                                            
                                    | 2289 |  | 				 (($chardata[$i]['eor'] == 'R') OR ($chardata[$i]['eor'] == 'EN') OR ($chardata[$i]['eor'] == 'AN'))) { | 
                                                            
                                    | 2290 |  | 					$chardata[$i]['type'] = 'R'; | 
                                                            
                                    | 2291 |  | 				} elseif ($chardata[$i]['type'] == 'N') { | 
                                                            
                                    | 2292 |  | 					// N2. Any remaining neutrals take the embedding direction | 
                                                            
                                    | 2293 |  | 					$chardata[$i]['type'] = $chardata[$i]['sor']; | 
                                                            
                                    | 2294 |  | 				} | 
                                                            
                                    | 2295 |  | 			} elseif ($chardata[$i]['type'] == 'N') { | 
                                                            
                                    | 2296 |  | 				// N2. Any remaining neutrals take the embedding direction | 
                                                            
                                    | 2297 |  | 				$chardata[$i]['type'] = $chardata[$i]['sor']; | 
                                                                                
                                |  | @@ 2295-2298 (lines=4) @@ | 
                                                            
                                    | 2292 |  | 					// N2. Any remaining neutrals take the embedding direction | 
                                                            
                                    | 2293 |  | 					$chardata[$i]['type'] = $chardata[$i]['sor']; | 
                                                            
                                    | 2294 |  | 				} | 
                                                            
                                    | 2295 |  | 			} elseif ($chardata[$i]['type'] == 'N') { | 
                                                            
                                    | 2296 |  | 				// N2. Any remaining neutrals take the embedding direction | 
                                                            
                                    | 2297 |  | 				$chardata[$i]['type'] = $chardata[$i]['sor']; | 
                                                            
                                    | 2298 |  | 			} | 
                                                            
                                    | 2299 |  | 			if ($chardata[$i]['level'] != $prevlevel) { | 
                                                            
                                    | 2300 |  | 				$levcount = 0; | 
                                                            
                                    | 2301 |  | 			} else { |