Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions plugin/vim.pl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ sub plugin_vim {
$text =~ s/(\s|\n)*$//gs;
$text .= "\n";

$text = font2span($text);

chdir($pwd);

# 캐쉬에 저장
Expand All @@ -98,4 +100,24 @@ sub plugin_vim {
return $text;
}

sub font2span {
my $html = shift;

my @colors = $html =~ m/color="#([^"]+)"/g;
my %colorMap;
$colorMap{$_}++ for @colors;
@colors = keys %colorMap;

my $style = "<style type=\"text/css\">\n";
for my $color (@colors) {
$style .= "._$color { color: #$color }\n";
}

$style .= "</style>\n";
$html = $style . $html;
$html =~ s/font color="#/span class="_/g;
$html =~ s/\/font/\/span/g;
return $html;
}

1;