[첫화면으로]UseModWiki소스수정/IncludeNoToc매크로

마지막으로 [b]

2 번째 수정본

includenotoc 매크로 추가

...
use vars qw(@RcDays @HtmlPairs @HtmlSingle
    ...
    $ConfigFile $SOURCEHIGHLIGHT %SRCHIGHLANG $LinkFirstChar $FS_lt $FS_gt);  # 끝에 $FS_lt $FS_gt 추가
...
sub InitLinkPatterns {
    ...
    $FS3 = $FS . "3";   # The FS character is not allowed in user data.
### 다음 두 줄 추가
    $FS_lt = $FS . "lt";
    $FS_gt = $FS . "gt";
###
    ...
}
sub WikiToHTML {
    ...
### 다음 두 라인 추가
    $pageText =~ s/$FS_lt/</g;
    $pageText =~ s/$FS_gt/>/g;
###
    return &RestoreSavedText($pageText);
}
sub MacroIncludeSubst {
    my ($txt) = @_;

    $txt =~ s/<include\((.*)\)>/&MacroInclude($1)/gei;
### 다음 라인 추가
    $txt =~ s/(^|\n)<includenotoc\((.*)\)>([ \t\r\f]*\n)/$1 . &MacroInclude($2, "notoc") . $3/geim;
###
    return $txt;
}
### 다음 함수를 새로 작성
sub MacroInclude {
    my ($name, $opt) = @_;

    if ($OpenPageName eq $name) { # Recursive Include 방지
        return "";
    }

    my $fname = &GetPageFile($name);    # 존재하지 않는 파일이면 그냥 리턴
    if (!(-f $fname)) {
        return "";
    }

    my $data = &ReadFileOrDie($fname);
    my %SubPage = split(/$FS1/, $data, -1);  # -1 keeps trailing null fields

    if (!defined($SubPage{"text_default"})) {
        return "";
    }

    my %SubSection = split(/$FS2/, $SubPage{"text_default"}, -1);
    my %TextInclude = split(/$FS3/, $SubSection{'data'}, -1);

    # includenotoc 의 경우
    $TextInclude{'text'} =~ s/<toc>/$FS_lt."toc".$FS_gt/gei if ($opt eq "notoc");
    return $TextInclude{'text'};
}

Notes

ext1.48c 에서 다시 수정되었습니다.
-- Raymundo 2003-9-15 8:41 pm


위키위키분류

이 수정본 편집일: 2003-9-15 8:41 pm (변경사항 [d])
845 hits | Permalink | 변경내역 보기 [h] | 현재 수정본 보기 | 2 번째 수정본 소스 보기