remove markdown
This commit is contained in:
parent
c477afabb0
commit
6920c10d2d
@ -6,5 +6,5 @@ include_once ('string.php');
|
||||
include_once ('numbers.php');
|
||||
include_once ('mail.php');
|
||||
include_once ('debug.php');
|
||||
include_once ('markdown.php');
|
||||
// include_once ('markdown.php');
|
||||
?>
|
||||
84
markdown.php
84
markdown.php
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
// TODO markdown imple
|
||||
function md($str) {
|
||||
// return nl2br ( $str ); // TODO md problem
|
||||
$text = '<p>';
|
||||
$lv = 0;
|
||||
$str = explode ( "\n", str_replace ( "\r\n", "\n", $str ) );
|
||||
// var_dump ( $str );
|
||||
foreach ( $str as $t ) {
|
||||
// echo '<pre>' . $t . '</pre>';
|
||||
$t = preg_replace_callback ( '/\[\[([^\]]*)\]\]/m', '_md_link_replacer', $t );
|
||||
$nlv = 0;
|
||||
if (startsWith ( $t, '**** ' )) {
|
||||
// echo - 1;
|
||||
$t = substr ( $t, 5 );
|
||||
$nlv = 4;
|
||||
}
|
||||
if (startsWith ( $t, '*** ' )) {
|
||||
// echo - 2;
|
||||
$t = substr ( $t, 4 );
|
||||
$nlv = 3;
|
||||
}
|
||||
if (startsWith ( $t, '** ' )) {
|
||||
// echo - 3;
|
||||
$t = substr ( $t, 3 );
|
||||
$nlv = 2;
|
||||
}
|
||||
if (startsWith ( $t, '* ' )) {
|
||||
// echo - 4;
|
||||
$t = substr ( $t, 2 );
|
||||
$nlv = 1;
|
||||
}
|
||||
if ($lv != $nlv) {
|
||||
while ( $lv < $nlv ) {
|
||||
// echo '-5 (' . $lv . '-' . $nlv . ')';
|
||||
$text .= '<ul>';
|
||||
$lv ++;
|
||||
}
|
||||
while ( $lv > $nlv ) {
|
||||
// echo '-6 (' . $lv . '-' . $nlv . ')';
|
||||
$text .= '</ul>';
|
||||
$lv --;
|
||||
}
|
||||
}
|
||||
if (startsWith ( $t, '!!!!! ' )) {
|
||||
$t = '<h5>' . substr ( $t, 6 ) . '</h5>';
|
||||
}
|
||||
if (startsWith ( $t, '!!!! ' )) {
|
||||
$t = '<h4>' . substr ( $t, 5 ) . '</h4>';
|
||||
}
|
||||
if (startsWith ( $t, '!!! ' )) {
|
||||
$t = '<h3>' . substr ( $t, 4 ) . '</h3>';
|
||||
}
|
||||
if (startsWith ( $t, '!! ' )) {
|
||||
$t = '<h2>' . substr ( $t, 3 ) . '</h2>';
|
||||
}
|
||||
if (startsWith ( $t, '! ' )) {
|
||||
$t = '<h1>' . substr ( $t, 2 ) . '</h1>';
|
||||
}
|
||||
if ($lv == 0) {
|
||||
if ($t == '') {
|
||||
$text .= '</p><p>';
|
||||
} else {
|
||||
$text .= $t;
|
||||
}
|
||||
} else {
|
||||
$text .= '<li>' . $t . '</li>';
|
||||
}
|
||||
// var_dump ( $t );
|
||||
}
|
||||
while ( $lv > 0 ) {
|
||||
$text .= '</ul>';
|
||||
$lv --;
|
||||
}
|
||||
$text .= '</p>';
|
||||
return $text;
|
||||
}
|
||||
function _md_link_replacer($in) {
|
||||
// var_dump ( $in );
|
||||
$in = explode ( '|', $in [1], 2 );
|
||||
|
||||
return '<a href="' . $in [0] . '" target="_blank">' . (isset ( $in [1] ) ? $in [1] : $in [0]) . '</a>';
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user