Skip to content
Snippets Groups Projects
Select Git revision
  • 8bd0d97b51abe5202a56a5da405357619c605b59
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

courseware.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    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 = '';