UTF-8이전작업/링크패턴 페이지의 소스 보기
마지막으로 [b]
-- Loading page list... --
내용출력
로그인[l]
Diary
[f]
최근변경내역
[r]
페이지목록[i]
횡설수설[2]
게시판[3]
링크
수정할 수 없습니다: UTF-8이전작업/링크패턴 는 읽기 전용 페이지입니다.
== # 링크 패턴 고치기 == InitLinkPatterns 에서 지정하는 각종 링크 패턴들을 UTF-8에 맞게 고쳐보자. === # 소스 수정 === ==== # 환경 변수 변동 ==== 불필요하다 싶은 옵션을 제거함 *
$SimpleLinks
옵션 삭제 - 항상 숫자와 "_"도 링크에 사용 가능 *
$NonEnglish
옵션 삭제 - 항상 비영어권 문자도 사용 가능 * 웬만하면
$FreeLinks
도 삭제하고 항상 이중 대괄호 링크를 쓸 수 있게 하고 싶지만 일단 보류 *
$LinkFirstChar
옵션을 삭제하고
$EditNameLink
옵션 추가 - 역할은 같은데, 이젠 이 값이 1일 경우는 페이지 이름 전체에 wikipageedit 클래스의 A 링크가 걸린다. (첫 글자만 링크 걸게 하지를 못하겠음) ==== # 추가되는 스타일쉬트 항목 ==== {{{#!vim css /* 위키 페이지 링크 */ A.wikipagelink:link, A.wikipagelink:active, A.wikipagelink:visited, A.wikipagelink:hover { background: transparent; color: green; text-decoration: none; } A.wikipagelink:hover { text-decoration: underline; } /* 위키 페이지 편집 링크 */ A.wikipageedit:link, A.wikipageedit:active, A.wikipageedit:visited, A.wikipageedit:hover { background: transparent; color: red; text-decoration: none; } A.wikipageedit:hover { text-decoration: underline; } }}} ==== # 바뀌는 패턴 ==== * $FS = "\x7f"에서 "\x1e"로. oddmuse에서 사용하는 값. 유즈모드1.0에서는 NewFS 변수가 1일 경우 "\x1e\xff\xfe\x1e"라는 긴 값을 쓰던데... 뭐 oddmuse가 어련히 알아서 했으리라 믿기로 함 그 외의 패턴은 InitLinkPatterns 함수의 diff로 설명을 대신함: 사실 패턴의 의미 자체가 달라진 건 거의 없고, oddmuse를 따라서 문자의 코드값 범위를 \x80-\xff 로 넓힌 게 핵심. {{{#!vim diff sub InitLinkPatterns { my ($UpperLetter, $LowerLetter, $AnyLetter, $LpA, $LpB, $QDelim); # Field separators are used in the URL-style patterns below. # $FS = "\xb3"; # The FS character is a superscript "3" - $FS = "\x7f"; + $FS = "\x1e"; # by gypark. from oddmuse $FS1 = $FS . "1"; # The FS values are used to separate fields $FS2 = $FS . "2"; # in stored hashtables and other data structures. $FS3 = $FS . "3"; # The FS character is not allowed in user data. ############### ### added by gypark $FS_lt = $FS . "lt"; $FS_gt = $FS . "gt"; ### ############### - - $UpperLetter = "[A-Z"; - $LowerLetter = "[a-z"; - $AnyLetter = "[A-Za-z"; - if ($NonEnglish) { - $UpperLetter .= "\xc0-\xde"; - $LowerLetter .= "\xdf-\xff"; - $AnyLetter .= "\xc0-\xff"; - } - if (!$SimpleLinks) { - $AnyLetter .= "_0-9"; - } - $UpperLetter .= "]"; $LowerLetter .= "]"; $AnyLetter .= "]"; + $UpperLetter = "[A-Z\xc0-\xde]"; + $LowerLetter = "[a-z\xdf-\xff]"; + $AnyLetter = "[A-Za-z\x80-\xff_0-9]"; # Main link pattern: lowercase between uppercase, then anything $LpA = $UpperLetter . "+" . $LowerLetter . "+" . $UpperLetter . $AnyLetter . "*"; # Optional subpage link pattern: uppercase, lowercase, then anything $LpB = $UpperLetter . "+" . $LowerLetter . "+" . $AnyLetter . "*"; if ($UseSubpage) { # Loose pattern: If subpage is used, subpage may be simple name $LinkPattern = "((?:(?:$LpA)?\\/$LpB)|$LpA)"; # Strict pattern: both sides must be the main LinkPattern # $LinkPattern = "((?:(?:$LpA)?\\/)?$LpA)"; } else { $LinkPattern = "($LpA)"; } $QDelim = '(?:"")?'; # Optional quote delimiter (not in output) -############### -### replaced by gypark -### anchor 에 한글 사용 -# $AnchoredLinkPattern = $LinkPattern . '#(\\w+)' . $QDelim if $NamedAnchors; - $AnchoredLinkPattern = $LinkPattern . '#([0-9A-Za-z\xa0-\xff]+)' . $QDelim if $NamedAnchors; -### -############### $LinkPattern .= $QDelim; # Inter-site convention: sites must start with uppercase letter # (Uppercase letter avoids confusion with URLs) $InterSitePattern = $UpperLetter . $AnyLetter . "+"; $InterLinkPattern = "((?:$InterSitePattern:[^\\]\\s\"<>$FS]+)$QDelim)"; + # free link [[pagename]] if ($FreeLinks) { # Note: the - character must be first in $AnyLetter definition - #if ($NonEnglish) { - $AnyLetter = "[-,.()' _0-9A-Za-z\xa0-\xff]"; - #} else { - # $AnyLetter = "[-,.()' _0-9A-Za-z]"; - #} + $AnyLetter = "[-,.()' _0-9A-Za-z\x80-\xff]"; } - $FreeLinkPattern = "($AnyLetter+)"; if ($UseSubpage) { $FreeLinkPattern = "((?:(?:$AnyLetter+)?\\/)?$AnyLetter+)"; + } else { + $FreeLinkPattern = "($AnyLetter+)"; } $FreeLinkPattern .= $QDelim; -############### -### added by gypark -### 한글패이지에 anchor 사용 -### from Bab2's patch - $AnchoredFreeLinkPattern = $FreeLinkPattern . '#([0-9A-Za-z\xa0-\xff]+)' . $QDelim if $NamedAnchors; -### -############### + # anchored link + $AnchorPattern = '#([0-9A-Za-z\x80-\xff]+)'; + $AnchoredLinkPattern = $LinkPattern . $AnchorPattern . $QDelim if $NamedAnchors; + $AnchoredFreeLinkPattern = $FreeLinkPattern . $AnchorPattern . $QDelim if $NamedAnchors; # Url-style links are delimited by one of: # 1. Whitespace (kept in output) # 2. Left or right angle-bracket (< or >) (kept in output) # 3. Right square-bracket (]) (kept in output) # 4. A single double-quote (") (kept in output) # 5. A $FS (field separator) character (kept in output) # 6. A double double-quote ("") (removed from output) - - $UrlProtocols = "http|https|ftp|afs|news|nntp|mid|cid|mailto|wais|mms|mmst|" - . "prospero|telnet|gopher"; - $UrlProtocols .= '|file' if $NetworkFile; + $UrlProtocols = 'http|https|ftp|afs|news|nntp|mid|cid|mailto|wais|mms|mmst|prospero|telnet|gopher|irc'; + $UrlProtocols .= '|file' if $NetworkFile; $UrlPattern = "((?:(?:$UrlProtocols):[^\\]\\s\"<>$FS]+)$QDelim)"; $ImageExtensions = "(gif|jpg|png|bmp|jpeg|GIF|JPG|PNG|BMP|JPEG)"; $RFCPattern = "RFC\\s?(\\d+)"; -############### -### replaced by gypark -### ISBN 패턴 수정 -# $ISBNPattern = "ISBN:?([0-9- xX]{10,})"; $ISBNPattern = "ISBN:?([0-9-xX]{10,})"; -### -############### } }}} === # 참고 자료 === Oddmuse 의 해당 함수: {{{#!vim perl sub InitLinkPatterns { my ($UpperLetter, $LowerLetter, $AnyLetter, $WikiWord, $QDelim); $QDelim = '(?:"")?';# Optional quote delimiter (removed from the output) $WikiWord = '[A-Z]+[a-z\x80-\xff]+[A-Z][A-Za-z\x80-\xff]*'; $LinkPattern = "($WikiWord)$QDelim"; $FreeLinkPattern = "([-,.()' _0-9A-Za-z\x80-\xff]+)"; # Intersites must start with uppercase letter to avoid confusion with URLs. $InterSitePattern = '[A-Z\x80-\xff]+[A-Za-z\x80-\xff]+'; $InterLinkPattern = "($InterSitePattern:[-a-zA-Z0-9\x80-\xff_=!?#\$\@~`\%&*+\\/:;.,]*[-a-zA-Z0-9\x80-\xff_=#\$\@~`\%&*+\\/])$QDelim"; $FreeInterLinkPattern = "($InterSitePattern:[-a-zA-Z0-9\x80-\xff_=!?#\$\@~`\%&*+\\/:;.,()' ]+)"; # plus space and other characters, and no restrictions on the end of the pattern $UrlProtocols = 'http|https|ftp|afs|news|nntp|mid|cid|mailto|wais|prospero|telnet|gopher|irc'; $UrlProtocols .= '|file' if $NetworkFile; my $UrlChars = '[-a-zA-Z0-9/@=+$_~*.,;:?!\'"()%]'; # see RFC 2396 my $EndChars = '[-a-zA-Z0-9/@=+$_~*]'; # no punctuation at the end of the url. $UrlPattern = "((?:$UrlProtocols):$UrlChars+$EndChars)"; $FullUrlPattern="((?:$UrlProtocols):$UrlChars+)"; # when used in square brackets $ImageExtensions = '(gif|jpg|png|bmp|jpeg)'; } }}} === # 의견 === 소스 보다가 잘 모르겠어서... $QDelim은 뭐하는 걸까요?
: 따옴표 두 개 쓰면 화면에는 안 보이는 구분자가 되지요. "Google:조프위키""를 보면" 여기서 '키'와 '를' 사이에 넣었습니다.
:: 앗 그렇군요. 감사합니다. 그러고보니 다른 위키에도 다 있는건데 왜 이걸 있을꺼라고 생각을 안했지...
---- [[위키위키분류]]
UTF-8이전작업/링크패턴
페이지로 돌아가기 |
다른 수정본 보기