svn: /web/doc-editor/trunk/php/ File.php

[email protected] (Yannick Torres)
Newsgroups php.doc.web
Message-ID <[email protected]>
yannick                                  Sun, 02 Jan 2011 23:32:08 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=307004

Log:
Part of resolution Bugs #51277. Clean Up entities, remove extra space from class's method, tag and inside tags

Bug: http://bugs.php.net/51277 (Assigned) google translate issues
      
Changed paths:
    U   web/doc-editor/trunk/php/File.php

Modified: web/doc-editor/trunk/php/File.php
===================================================================
--- web/doc-editor/trunk/php/File.php	2011-01-02 22:23:33 UTC (rev 307003)
+++ web/doc-editor/trunk/php/File.php	2011-01-02 23:32:08 UTC (rev 307004)
@@ -118,6 +118,23 @@
         $translation = str_replace("&quot;", '"', $translation);
         $translation = str_replace("&lt;"  , '<', $translation);
         $translation = str_replace("&gt;"  , '>', $translation);
+
+        // CLeanUp entities. Google return it like this : & Reftitle.parameters;. We convert it like this : &reftitle.parameters;
+        $translation = preg_replace_callback("/(&)\s(.)(.[^;]*?)(;)/s",
+            create_function(
+                '$matches',
+                'return $matches[1].strtolower($matches[2]).$matches[3].$matches[4];'
+            ),
+        $translation);
+
+        // We remove extra space after :: operator
+        $translation = preg_replace("/(\w+)(::)(\s)(\w+)/s", "$1$2$4", $translation);
+
+        // We delete space into tab like this </ b>
+        $translation = preg_replace("/(<\/\s(\w+[^>]*)>)/s", "</$2>", $translation);
+
+        // We delete space just after an open tag, and just before a close tag, like this <b> foo </b>
+        $translation = preg_replace("/(<(\w+[^>]*)>)(\s?)(.[^>]*?)(\s?)(<\/(\\2)>)/s", "<$2>$4</$7>", $translation);

         return $translation;
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.