markup angefangen
This commit is contained in:
parent
9a915302d1
commit
555240506b
59
string.php
59
string.php
@ -66,5 +66,64 @@ function isEmail($str) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
function markUp($text) {
|
||||||
|
$r = '';
|
||||||
|
$lv = 0;
|
||||||
|
foreach ( explode ( "\n", $text ) as $t ) {
|
||||||
|
$nlv = 0;
|
||||||
|
if (startsWith ( '**** ', $t )) {
|
||||||
|
$t = substr ( $t, 5 );
|
||||||
|
$nlv = 4;
|
||||||
|
}
|
||||||
|
if (startsWith ( '*** ', $t )) {
|
||||||
|
$t = substr ( $t, 4 );
|
||||||
|
$nlv = 3;
|
||||||
|
}
|
||||||
|
if (startsWith ( '** ', $t )) {
|
||||||
|
$t = substr ( $t, 3 );
|
||||||
|
$nlv = 2;
|
||||||
|
}
|
||||||
|
if (startsWith ( '* ', $t )) {
|
||||||
|
$t = substr ( $t, 2 );
|
||||||
|
$nlv = 1;
|
||||||
|
}
|
||||||
|
if ($lv != $nlv) {
|
||||||
|
while ( $lv < $nlv ) {
|
||||||
|
$text .= '<ul>';
|
||||||
|
$lv ++;
|
||||||
|
}
|
||||||
|
while ( $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) {
|
||||||
|
$r .= $t;
|
||||||
|
} else {
|
||||||
|
$r .= '<li>' . $t . '</li>';
|
||||||
|
}
|
||||||
|
// var_dump ( $t );
|
||||||
|
}
|
||||||
|
while ( $lv > 0 ) {
|
||||||
|
$r .= '</ul>';
|
||||||
|
$lv --;
|
||||||
|
}
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user