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

마지막으로 [b]

1. Footnote 매크로
1.1. 사용법
1.1.1. ext2.1j - 동일한 내용의 각주가 두 번 이상 나올 때
1.2. 부작용
1.3. wiki.pl 수정
1.4. macros/footnote.pl 추가
1.5. translations/korean.pl 수정
1.6. wiki.css 수정
1.7. 추가 업데이트 내역
1.8. 사용자 의견

1. Footnote 매크로

Jof:UseModWiki소스수정/각주매크로 를 적용

1.1. 사용법

<footnote(내용)>

예:

오른쪽의 각주 번호를 클릭하세요<footnote(여기에 각주가 들어감)>
오른쪽의 각주 번호를 클릭하세요1

1.1.1. ext2.1j - 동일한 내용의 각주가 두 번 이상 나올 때

두 개 이상의 각주 매크로에서 괄호 안의 내용이 동일한 경우에, 그 각주는 본문 하단에 한번만 표시되고 왼쪽에 각각의 각주 번호가 나란히 나온다.

홍길동<footnote(아들)>이 어쩌고 저쩌고...
홍판서<footnote(길동 애비)>가 어쩌고 저쩌고...
다시 홍길동<footnote(아들)>이 이러쿵 저러쿵...
임금<footnote(당시 왕이 누구더라만)>이 홍길동<footnote(아들)>에게...
홍길동2이 어쩌고 저쩌고...
홍판서3가 어쩌고 저쩌고...
다시 홍길동4이 이러쿵 저러쿵...
임금5이 홍길동6에게...

1.2. 부작용

부작용이라 할 수는 없지만... 긁어서 퍼갈때 각주 번호들이 같이 복사되니 불편하다. 7 필요한 곳에서만 쓰자. :-)

1.3. wiki.pl 수정

/매크로모듈화에 따라서 wiki.pl에서 분리해서 별도의 footnote.pl로 옮겼음

1.4. macros/footnote.pl 추가

use strict;

my $MyFootnoteCounter;
my @MyFootnotes;
my %SaveNumFootnote;

sub footnote {
    my ($txt) = @_;

    $MyFootnoteCounter = 0;
    $txt =~ s/(&__LT__;footnote\(([^\n]+?)\)&__GT__;)/&MacroFootnote($2)/gei;

    # 본문 하단에 각주 출력
    if ($MyFootnoteCounter > 0) {
        map { s/_MARK_// } @MyFootnotes;
        $txt .= "<DIV class='footnote'>".
            "\n" . T('Footnote') . ": <br>\n".
            join('', @MyFootnotes). "</DIV>";
    }

    return $txt;
}

sub MacroFootnote {
    my ($note) = @_;

    $MyFootnoteCounter++;
    my $number = "<A name='FN_$MyFootnoteCounter' href='#FNR_$MyFootnoteCounter'>$MyFootnoteCounter</A>.";

    # URL이 있을 경우 동일한 내용이란 걸 파악하기 위해서, Restore를 해 줘야 함
    my $note_restored = &RestoreSavedText($note);   # 내용 비교는 이 변수를 사용

    if (defined $SaveNumFootnote{$note_restored}) {
        # 동일한 내용의 각주가 이미 있다면 그 각주에다가 새 번호 삽입
        $MyFootnotes[$SaveNumFootnote{$note_restored}] =~ s/_MARK_/$number _MARK_/;
    } else {
        # 새로운 내용의 각주 추가
        push @MyFootnotes,
             $number.
            " _MARK_$note".
            "<br>\n";
        $SaveNumFootnote{$note_restored} = $#MyFootnotes;
    }
    return "<A class='footnote' name='FNR_$MyFootnoteCounter' href='#FN_$MyFootnoteCounter'>$MyFootnoteCounter</A>";
}

1;

1.5. translations/korean.pl 수정

필요하면 다음 번역 추가
Footnote
각주

1.6. wiki.css 수정

A.footnote 와 DIV.footnote 를 적절히 고쳐 준다. 아래는 예.
DIV.footnote {
    border-top:1px solid silver;
    padding:5px;
}

A.footnote {
    font-size: 80%;
    vertical-align: super;
}

1.7. 추가 업데이트 내역

ext1.60b - a name= 뒤에 #을 제거
-- Raymundo 2004-3-23 10:44 pm

ext2.1j - 동일한 내용의 각주는 각주 번호를 모아서 한번만 출력함

ext2.8a - 동일한 내용의 각주이지만 각주 내용에 링크가 포함되어 있어서 서로 다른 내용으로 간주되는 문제 해결

-- Raymundo 2008-8-5 12:37 am

1.8. 사용자 의견

각주매크로를 화면 하단이 아니라 팝업(?)으로 뜨게할수 없을까요?
-- Bab2 2004-3-12 10:05 pm
안녕하세요, 핸드스토리 베타테스터에 합격하신 분과는 삐져서 대화할 수 없습니다. ^^;; 팝업이 되었든 floating object 가 되었든간에 html 소스만 그렇게 출력해주면 되겠죠. 근데 a 태그에 title 속성을 주면 마우스를 갖다대었을 때 뜨지 않을까 싶네요.
-- Raymundo 2004-3-12 10:11 pm
방금, title 속성에 주석의 내용을 넣도록 고쳤다가 낭패를 봤네요. 각주 안에 위키네임이나 페이지링크가 들어갈 경우 그게 a href 로 변한 다음에 footnote 가 적용이 되니까, a 태그 안에 다시 a 태그가 들어가면서 난리가 납니다. 해결책을 찾기 전에는 (제가 직접 찾을 생각은 없습니다 ^^) 어찌할 수 없겠습니다.
-- Raymundo 2004-3-12 10:52 pm
헉~ 자바스크립트로 어떻게 해결안될까요...ㅜㅡ?
-- Bab2 2004-3-12 11:00 pm
제가 자바스크립트에는 완전 문맹이란 것을 익히 아실터이니... 누군가 가르쳐 주기 전까지는 해결 안 되겠군요 :-)
-- Raymundo 2004-3-13 12:12 am

a name= 뒤에 있는 #을 둘 다 제거하고 테스트해주시기 바랍니다. 제가 원래 소스에 하나는 #을 붙이고 하나는 안 붙였던 것 같네요. #이 있으면 불여우등에서 안되더군요.

-- 조프 2004-3-23 6:15 pm

어라, 그러고 보니 그러네요. ^^;
-- Raymundo 2004-3-23 10:20 pm

수정했습니다.
-- Raymundo 2004-3-23 10:44 pm

Diary/URL링크를번호로출력하기에 언급한 것처럼, 각주의 내용이 동일하면, 하단에는 그 내용을 한번만 출력하게 해볼까 합니다.

그런데 문제는, 예를 들어 본문에서 각주로 갈 때는 여러 곳에서 하나의 각주로 이동하는 거니까 상관이 없는데, 반대로 각주에서 본문으로 이동할 때는 하나의 각주에서 본문의 여러 곳으로 이동해야 하니까 어디로 이동할 지 모른다는 건데요...

일단 각주에는, 색인매크로처럼 번호를 각각 적어주면 될 것 같습니다.
각주:
1, 3 홍길동
2 홍판서

"홍길동"의 경우 1을 누르면 본문의 첫번째로, 3을 누르면 두번째 등장하는 곳으로 가게 하면 되죠.

그럼 본문에 어떻게 표시할까가 문제인데,
1) 첫번째 안: (괄호 안 번호가 각주 번호)
본문: 홍길동(1)이 어쩌고, 홍판서(2)가 어쩌고, 그래서 홍길동(3)이 다시 어쩌고
2) 두번째 안:
본문: 홍길동(1)이 어쩌고, 홍판서(2)가 어쩌고, 그래서 홍길동(1)이 다시 어쩌고

즉, 두번째 홍길동은, 눈에는 "1"로 보이지만 클릭하면 하단의 "3"으로 갑니다. 반대로 하단의 "3"을 클릭하면 저 두번째 홍길동으로 갑니다.

이건, 본문을 보고 있을 때는 "아 이건 아까 나왔던 홍길동과 같은 각주로구나"라는 걸 더 확실히 알 수 있다는 게 장점이고, 반대로 본문의 번호와 하단의 번호가 일치하지 않는다는 게 단점.

어느게 나을지 모르겠네요.

-- Raymundo 2007-3-12 8:38 am

그러네요. 근데 논문같은데서 각주 4를 보러갔더니 "1장 각주 3을 참고" 이런 식으로 나오는 경우도 있어서 1번이 괜찮을 것 같기도 하고... 동일 내용을 생각하면 두번재 안이 좋을 것 같기도 하고..
-- Nyxity 2007-3-12 9:00 am

그냥 1번 안으로 일단 할께요, 번호가 서로 일치하지 않는 것도 좀 그렇고, 보여지는 번호와 실제 번호를 별개로 유지하려니 그것도 일이라서...

-- Raymundo 2007-3-12 9:04 am

아 그러고보니 Nyxity님이 얘기하신 논문 식으로 한다면, 하단 각주 쪽을
각주:
1. 홍길동
2. 홍판서
3. 각주1과 동

이런 식으로 표시해도 되긴 하겠군요.

-- Raymundo 2007-3-12 9:16 am

으음, 각주에 URL 이나 [URL 설명] 등의 외부 링크가 들어가 있으면 이게 동일한 링크라 하더라도 서로 다른 각주로 취급되는군요. 외부 링크를 따로 저장하면서 본문에 링크가 있던 자리에는 고유번호를 넣어두고 제일 마지막에 그 링크들을 다시 채워넣는 순서라서... 각주가 처리되는 시점에는 이게 동일한 내용이 아닌 걸로 나옵니다. 다른 웹페이지의 내용을 인용할 때 각주에 쓰면 결국 매번 별도의 각주 번호가 붙는... [URL] 형식과 같이 쓰든가 해야겠습니다.

예전부터 느꼈던 거지만, 매크로 치환을 더 뒤로 빼던가 아니면 더 앞으로 당기던가 해야 좋을 것 같긴 한데.... 기존에 작성한 페이지들이 어떻게 될 지 몰라서 못 하겠네요.

-- Raymundo 2007-5-6 12:53 am

8

-- 조프 2009-12-22 12:47 am

아니 이건 웬 뜬금없는 각주입니까? :-)
-- Raymundo 2009-12-22 12:53 am

Jof:UseModWiki소스수정/각주매크로 좀 무자비하게 고쳐봤습니다. 어차피 많이 쓰는 것도 아닌데... 라는 생각이 들어서.
-- 조프 2009-12-22 2:22 am

Hi from Europe,
Really I still don't understand RestoreSavedText. In this same direction, is there any scenario where the old version of footnote's patch, gives errors? (because before, it used $note, now "restored_note).
Humorous:
Infinite is just the number 5186 (the current lines of code from ascendant Usemod).
Thanks anyway and good weekend.

-- JuanmaMP 2012-5-20 2:19 am

It's needed because of the behavior of Usemodwiki.

At first, this footnote patch treated each footnote independently.

Next, I thought that if more than one footnote have same text, it would be good to show them in one line.

example)
1. a footnote
2. 4. 6. same text for three footnotes
3. another footnote
...

But I found a problem that if the footnote include a URL, usemod stored the URL and replaced it with index numbers. Let's assume the above footnote 2,4,and 6 is "same url http://url", then they are shown as:
2. same url 1
...
4. same url 2
...
6. same url 3

And then, the index numbers are replaced with URL again (that is, restored) before printed. So, my patch fails to show them in one line.

The patch of current version, using "RestoreSavedText", is to resolve the problem. Now this macro tries to restore URL at first, and then compare the content of footnotes to see they are same or not.

I wish you could understand my poor English :-)
-- Raymundo 2012-5-20 3:19 am

it perfectly understood the matter in english, now it's my turn to understand about usemod's behavior. Sincerely, big thanks.

-- JuanmaMP 2012-5-20 4:01 am

Oh!, I understand a little more. I had included:
if ($MyFootnoteCounter > 0) {...}
into core script directly (at WikiToHTML, without MacroSubst); thus, that casually, I didn't see the side effect, I guess; but not least, knowing, this implication.

-- JuanmaMP 2012-5-20 4:56 am

해외에서 안녕. (kk)
Hi, Raymundo,
this seems to give error, url needs spaces or whatever at the end, inside footnote:
9

It's been long time! How are you? :-)

You are right. I've been aware of that problem for years. :'(

URL processing is performed *before* macro processing. So it seems that it needs much more work than it looks to fix the problem. I don't know how to fix it with simple modification.
-- Raymundo 2013-12-10 9:38 pm

How am i?
Hmmm, I feel oldest than when I made the first question here! (Obviously).

On the question before us now, I have the bad habit of putting all the features in the core code and ‘et voilà’. Let's say

 
sub WikiToHTML {
...
+ if ($MyFootNoteCounter > 0) {
+ map {s/_MARK_//} @MyFootnotes;
+ $pageText .= '<div class=clear></div><hr class=footnote>';
+ $pageText .= '<span class=foot>' . CommonMarkup(join(' ', @MyFootnotes)) . '</span>';
+ }
...
while (@HeadingNumbers) {
...
}

sub CommonMarkup {
...
+ s/(\[\[\[([^\n]+?)\]\]\])/FootNote($2)/ige; # I have the syntaxis [[[blah blah]]]
s/^{{{\r?\n(.*?)\n}}}\r?$/StoreRaw(qq|<pre class="code">\n|) . StoreCodeRaw($1) . StoreRaw("\n<\/pre>")/igesm;


What do you think?. Any drawbacks?
Big thanks.
-- JuanmaMP 2013-12-12 8:20 am

Umm... Frankly speaking, I don't know. There may be any side effect that we couldn't imagine, or not.
-- Raymundo 2013-12-12 10:43 pm
이름:  
Homepage:
내용:
 

위키위키분류
각주:
1. 여기에 각주가 들어감
2. 4. 6. 아들
3. 길동 애비
5. 당시 왕이 누구더라만
7. /빈페이지와 같은 맥락
8. UseModWiki
9. http://www.google.com)&__GT__; <mysign(JuanmaMP,2013-12-9 9:10 pm

마지막 편집일: 2013-12-12 10:43 pm (변경사항 [d])
1523 hits | Permalink | 변경내역 보기 [h] | 페이지 소스 보기