[ZF-10089] Zend_Log
[zend.git] / documentation / manual / id / tools / programlisting.php
blobefcfc0fd91878ffe4297aa384802243a074cbbd1
1 <?php
2 $dir = new DirectoryIterator('../module_specs/');
4 function InsertSpace($matches)
6 return $matches[1].$matches[2].$matches[3].str_pad(' ',strlen($matches[1])).$matches[4];
9 foreach ($dir as $file)
11 if ($file->isFile()) {
12 $text = file_get_contents($file->getPathName());
13 // Put \n after CDATA if none
14 $text = preg_replace('/(\<\!\[CDATA\[)([^\n])/', "$1\n$2", $text);
15 // Omit space (not \n) before ]]>
16 $text = preg_replace('/([^\n])(\s*)(\]\]\>\<\/programlisting\>)/', "$1\n$3", $text);
17 // Reset all space between ]]> and </programlisting>
18 $text = preg_replace('/(\]\]\>)(\n|\s)*(\<\/programlisting\>)/', "$1$3", $text);
19 // Omit last ? > of the programlisting
20 $text = preg_replace('/(\?\>)(\n|\s)*(\]\]\>)/', "$2$3", $text);
21 // Put \n before ]]> if none
22 $text = preg_replace('/([^\n])(\]\]\>)(\<\/programlisting\>)/', "$1\n$2$3", $text);
23 // Put \n between ]]> and </programlisting>
24 $text = preg_replace('/(\]\]\>)(\<\/programlisting\>)/', "$1\n$2", $text);
25 // Put same indent before </programlisting> as before <programlisting>
26 $text = preg_replace_callback('/([^\n]*)(<programlisting role="php"><)(.*?)(<\/programlisting>)/s', "InsertSpace", $text);
27 file_put_contents($file->getPathName(),$text);