Select Git revision
courseware.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Closes #1632 Merge request studip/studip!1103
Closes #1632 Merge request studip/studip!1103
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
TextFormatTest.php 11.92 KiB
<?php
/*
* text_format_test.php - unit tests for the TextFormat class
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Elmar Ludwig
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
function markupLine($markup, $matches)
{
return '<hr>';
}
function markupHeading($markup, $matches)
{
$level = max(1, 5 - mb_strlen($matches[1]));
return sprintf('<h%d class="content">%s</h%d>', $level, $markup->format($matches[2]), $level);
}
function markupText($markup, $matches, $contents)
{
static $tag = [
'**' => 'b',
'%%' => 'i',
'__' => 'u',
'##' => 'tt',
'++' => 'big',
'--' => 'small',
'>>' => 'sup',
'<<' => 'sub',
'{-' => 'strike'
];
$key = $matches[0];
return sprintf('<%s>%s</%s>', $tag[$key], $contents, $tag[$key]);
}
function markupSimple($markup, $matches)
{
static $tag = [
'*' => 'b',
'%' => 'i',
'_' => 'u',
'#' => 'tt',
'+' => 'big',
'-' => 'small',
'>' => 'sup',
'<' => 'sub'
];
$key = $matches[0][0];
$text = str_replace($key, ' ', $matches[1]);
return sprintf('<%s>%s</%s>', $tag[$key], $markup->quote($text), $tag[$key]);
}
function markupImage($markup, $matches)
{
if (mb_strlen($matches[1]) > 1) {
$title = $markup->format(mb_substr($matches[1], 1));
} else {
$title = '';