コード例 #1
0
function view_macro_reflist($args)
{
    return parse_elements(new_entity(array("reflist", $args)));
}
コード例 #2
0
function parse_table($text)
{
    static $in_table = 0;
    $pre = '';
    $post = '';
    if (preg_match('/^(\\|\\|)+.*(\\|\\|)\\s*$/', $text)) {
        if (!$in_table) {
            $pre = html_table_start();
            $in_table = 1;
        }
        $text = preg_replace('/^((\\|\\|)+)(.*)\\|\\|\\s*$/e', "new_entity(array('raw',html_table_row_start().html_table_cell_start(strlen('\\1')/2)))." . "q1('\\3').new_entity(array('raw',html_table_cell_end().html_table_row_end()))", $text, -1);
        $text = preg_replace('/((\\|\\|)+)/e', "new_entity(array('raw',html_table_cell_end().html_table_cell_start(strlen('\\1')/2)))", $text, -1);
    } else {
        if ($in_table) {
            $in_table = 0;
            $pre = html_table_end();
        }
    }
    if ($pre != '') {
        $text = new_entity(array('raw', $pre)) . $text;
    }
    if ($post != '') {
        $text = $text . new_entity(array('raw', $post));
    }
    return $text;
}
コード例 #3
0
ファイル: transforms.php プロジェクト: apenwarr/gracefultavi
function parse_redirect($text)
{
    global $action, $no_redirect, $page, $version;
    if (preg_match('/^#redirect\\s+\\[?(.*?)\\]?\\s*$/i', $text, $matches) && validate_page($matches[1])) {
        if ($no_redirect || $action != 'view' || isset($version)) {
            $text = new_entity(array('raw', '#redirect ')) . wikiname_token($matches[1], '');
        } else {
            header('Location: ' . viewUrl($matches[1]) . '&redirect_from=' . $page);
            exit;
        }
    }
    return $text;
}
コード例 #4
0
function parse_odt_newline($text)
{
    static $last = array('', '');
    // treat lines with only spaces as empty
    $thisline = preg_replace('/^ */', '', $text);
    // More than two consecutive newlines fold into only two newlines.
    if ($last[0] == "\n" && $last[1] == "\n" && $thisline == "\n") {
        return '';
    }
    $last[0] = $last[1];
    $last[1] = $thisline;
    if ($thisline == "\n" || $thisline == "\n\r") {
        $text = new_entity(array('raw', odt_paragraph_end())) . new_entity(array('raw', odt_paragraph_start())) . new_entity(array('raw', odt_paragraph_end())) . new_entity(array('raw', odt_paragraph_start())) . $text;
    }
    // deal with <br>
    $text = preg_replace('/<br>/i', new_entity(array('raw', odt_paragraph_end())) . new_entity(array('raw', odt_paragraph_start())), $text);
    return $text;
}
コード例 #5
0
function parse_table($text)
{
    static $in_table = 0;
    $pre = '';
    $post = '';
    if (preg_match('/^(\\|\\|)+(\\{([^{}]+)\\})?.*(\\|\\|)\\s*$/', $text, $args)) {
        if (!$in_table) {
            $pre = html_table_start($args[3]);
            $in_table = 1;
        }
        $text = preg_replace('/\\|\\s+\\|/e', "q1('|').new_entity(array('raw','&nbsp;')).q1('|')", $text);
        $text = preg_replace('/^((\\|\\|+)(\\{([^{}]+)\\})?)(.*)\\|\\|\\s*$/e', "new_entity(array('raw',html_table_row_start('\\4').\r\n                                                 html_table_cell_start(strlen('\\2')/2, '\\4')))." . "q1('\\5').new_entity(array('raw',html_table_cell_end().html_table_row_end()))", $text, -1);
        $text = preg_replace('/((\\|\\|+)(\\{([^{}]+)\\})?)/e', "new_entity(array('raw',html_table_cell_end().html_table_cell_start(strlen('\\2')/2, '\\4')))", $text, -1);
    } else {
        if ($in_table) {
            $in_table = 0;
            $pre = html_table_end();
        }
    }
    if ($pre != '') {
        $text = new_entity(array('raw', $pre)) . $text;
    }
    if ($post != '') {
        $text = $text . new_entity(array('raw', $post));
    }
    return $text;
}