{{{#!vim [c|sh|...] [number] code }}}
#!/usr/bin/perl if ($condition) { print "Hello, World!\n"; }
vim 6.4 이후부터, 변환된 출력의 글꼴 색상이 매우 이상하게 나오고 불필요해보이는 밑줄까지 그어져서 나오는 문제가 있다.
현재 딱히 해결방법은 없고, GyparkWiki에서는 다음과 같이 임시로 처리해둔 상태:
sub plugin_vim { my ($content, @opt) = @_; # my $vim = "vim"; # PATH of vim my $vim = "/home/gypark/local/bin/vim63"; # 이런 식으로 my $tohtml = "syntax/2html.vim"; ... }
# vim plugin # 박원규님의 MoniWiki 의 vim.php 의 코드를 흉내내었음. # # usage : # {{{#!vim sh|c|sh|.. [number] # some codes # }}} sub plugin_vim { my ($content, @opt) = @_; my $vim = "vim"; # PATH of vim my $tohtml = "syntax/2html.vim"; my $text; my $status; my $option; my $type = "nosyntax"; foreach my $opt (@opt) { if ($opt eq "number") { $option='+"set number" '; } elsif ($opt =~ /^\w+$/) { $type = $opt; } } $content =~ s/\r//g; # html파일의 이름 결정 my $hash; my $hasMD5 = eval "require Digest::MD5;"; if ($hasMD5) { $hash = Digest::MD5::md5_base64($content.join('',@opt)); } else { $hash = crypt($content, $HashKey); } $hash =~ s/(\W)/uc sprintf "_%02x", ord($1)/eg; my $hashhtml = "$hash.html"; my $VimDir = "$UploadDir/vim"; if ($hasMD5 and -f "$VimDir/$hashhtml" && not -z "$VimDir/$hashhtml") { # 이미 생성되어 캐쉬에 있음 ($status, $text) = &ReadFile("$VimDir/$hashhtml"); return $text if $status; } # 캐쉬에 없거나, 읽는 데 실패하면 새로 작성 &CreateDir($UploadDir); &CreateDir($VimDir); my $hashdir = "$TempDir/$hash"; if (not -d $hashdir) { mkdir($hashdir, 0775) or return "[Unable to create $hash dir]"; } my $pwd = `pwd`; $pwd =~ s/(.*)(\n|\r)*/$1/; chdir ($hashdir); # html 생성 my $tmpi = "$hash.in"; my $tmpo = "$hash.out"; open (OUT, ">$tmpi") or return "[Unable to open $tmpi file]"; print OUT $content; close(OUT); open SAVEOUT, ">&STDOUT"; open SAVEERR, ">&STDERR"; open STDOUT, ">hash.log"; open STDERR, ">&STDOUT"; qx($vim -T xterm -e -s $tmpi +"set enc=$HttpCharset" +"syntax on" +"set syntax=$type" $option +"ru! $tohtml" +"wq! $tmpo" +q); close STDOUT; close STDERR; open STDOUT, ">&SAVEOUT"; open STDERR, ">&SAVEERR"; # html 가공 및 옮김 ($status, $text) = &ReadFile("$tmpo"); if (!$status) { return undef; } $text =~ s/<title>.*title>|<\/?head>|<\/?html>|<meta.*>|<\/?body.*>//g; $text =~ s/^.*?<pre>/<pre class='vim'>/gs; $text =~ s/^(\s|\n)*//gs; $text =~ s/(\s|\n)*$//gs; $text .= "\n"; chdir($pwd); # 캐쉬에 저장 if ($hasMD5 and open (OUT, ">$VimDir/$hashhtml")) { print OUT $text; close(OUT); } unlink (glob("$hashdir/*")) or return "[unlink fail]"; rmdir ($hashdir) or return "[rmdir fail]"; return $text; } 1;
/* vim plugin */ PRE.vim { font: normal normal normal 105%/160% FixedSys, Lucida Console, Courier New, monospace; border: 1px solid silver; padding: 0.5em 0.5em 0.5em 0.5em; white-space:pre; text-align:justify; width:90%; background: black; color: #c0c0c0; }
ext1.74e
ext1.76a - 미리 보기를 하면 \r 캐릭터 때문에 변환 후 "^M"이 출력되는 문제 수정
ext2.9a - 플러그인의 출력으로 나오는 pre 태그의 스타일을 UseModWiki스타일쉬트에서 지정할 수 있게 수정
ext2.26a - html_use_css=1
옵션을 주어서, font 태그를 쓰지 않고 span 태그와 스타일쉬트를 사용하는 형태로 변환하게 함. 구체적인 변경 내역은 [vim plugin - CSS를 사용하도록 수정 · 55f970b · gypark/UseModKr] 참고