edit.inc.php

Top > Old > Hack > edit.inc.php
First Edition. 06/08/2006
Last Modified. 06/08/2006

Hack:Partedit including sub-sections - Now Plus had this

SummaryPartedit including sub-sections
Revision1.1
Compatible VersionsVerified with 1.4.6-u2-i18n
Developersonots
First Edition06/08/2006
Last Modified06/08/2006
LicenseGPL
Table of Contents

This page is written in both English and Japanese.

Abstract

This hack of edit.inc.php extends the part edit functionality of pukiwiki plus and enables to part-edit a section including subsections not from a section to next section in spite of their heading levels.

That is, default way was,

*Heading 1
Only here
**Heading 2
*Heading 1

but this enables to edit like belows.

*Heading 1
**Heading 2
Until here
*Heading 1

We often move writing among subsections. This plugin supports doing that.

Related

Source codes

I changed edit.inc.php#plugin_edit_parts into

// Replace/Pickup a part of source
function plugin_edit_parts($id, &$source, $postdata='')
{
    $postdata = rtrim($postdata) . "\n";
    $start = -1;
    $end   = count($source);
    foreach ($source as $i => $line) {
        if ($start == -1) {
            if (preg_match("/^(\*{1,3})(.*?)\[#($id)\](.*?)$/m", $line, $matches)) {
                $start = $i;
                $hlen  = strlen($matches[1]);
            }
        } else {
            if (preg_match("/^(\*{1,3})/m", $line, $matches) && strlen($matches[1]) <= $hlen) {
                $end = $i;
                break;
            }
        }
    }
    if ($start == -1) {
        return FALSE;
    } else {
        return join('', array_splice($source, $start, $end - $start, $postdata));
    }
}

Comments

./Note?