1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
/*
* Manage object main to rectify segun Markdown's definition
* */
private static function mngMain() {
$index = null;
$main = self::$main; //var_dump($main);
$sign = false;
$b = $b1 = $b2 = $b3 = array();
$b1 = preg_grep('/^>{1,}/', $main); //var_dump($b1);
$k = array_key_last($b1);
$k2 = array_keys($b1, '> --'); var_dump($k2);
$b1[$k2] = '> -- ```';
$b1[$k+1] = "```"; //var_dump($b1);
//if(!empty($b1)) {
//$b2 = preg_grep('/^>{2}/', $b1);
//if(!empty($b2)) {
//$k = array_key_last($b2);
//$b2[$k+1] = ">";
//var_dump($b2);
////$b3 = preg_grep('/^>{3}/', $b2);
////if(!empty($b3)) {
////$k = array_key_last($b3);
//////array_unshift($b3, ">>");
////$b2 = array_replace_recursive($b2, $b3);
////}
//$b1 = array_replace_recursive($b1, $b2);
//}
//$b3 = preg_grep('/^>{3}/', $b1);
//if(!empty($b3)) {
//$k = array_key_last($b3);
//$b3[$k+1] = ">>";
////$b1 = array_replace_recursive($b1, $b3);
//}
//}
$main = array_replace_recursive($main, $b1);
var_dump($main);
//foreach($main as $key => $line) {
//// if line start with '*' and end with ':'...
//$main[$key] = preg_replace('/^\* (.*?):$/',"\n".'${1}:', $line);
///*
//* Treatment for blockquote: search all lines started with '>'.
//*
//* */
//if(strpos($line, '>', 0) !== FALSE) {
//// if line is only '> --', rewrite with start code block MD
//if(strcmp($line, '> --') == 0) {
//$sign = true;
//$main[$key] = ">\n \n> ```";
//}
//// if line start with '> *'
////elseif(strpos($line, '> *', 0) !== FALSE) {
////$main[$key] = preg_replace('/^\> \* (.*?):$/',"\n".'> ${1}:', $line);
////}
////elseif(strpos($line, '>>', 0) !== FALSE) {
//////$main[$key] = "\n".$line;
////preg_match('/^>>/', $line, $m); var_dump($m);
////}
//else $main[$key] = $line;
//$index = $key;
//}
//}
////unset($key, $line);
//// if exist line with '> --', then add end code block MD
//if($sign) $main[$index] = $main[$index]."```\n";
unset($sign, $index);
self::$main = implode("\n",$main); //var_dump(self::$main);
return self::$main;
unset($main);
} |
Partager