Created
December 30, 2012 19:44
-
-
Save tyru/4414639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- vim2html.pl.bak 2013-01-27 19:33:42.945919677 +0900 | |
+++ vim2html.pl 2013-01-27 19:33:41.797918006 +0900 | |
@@ -19,7 +19,7 @@ | |
return $url{ $tag }; | |
} else { | |
#warn "Unknown hyperlink target: $tag\n"; | |
- $tag =~ s/\.txt//; | |
+ $tag =~ s/\.(?:txt|..x)//; | |
$tag =~ s/</</g; | |
$tag =~ s/>/>/g; | |
return "<code class=\"badlink\">$tag</code>"; | |
@@ -38,8 +38,8 @@ | |
$tag = $1; | |
my $label = $tag; | |
- ($file= $2) =~ s/.txt$/.html/g; | |
- $label =~ s/\.txt//; | |
+ ($file= $2) =~ s/.(?:txt|..x)$/.html/g; | |
+ $label =~ s/\.(?:txt|..x)//; | |
$url{ $tag } = "<a href=\"$file#".escurl($tag)."\">".esctext($label)."</a>"; | |
} | |
@@ -75,9 +75,12 @@ | |
my( $outfile ); | |
open(IN, "$infile" ) || die "Couldn't read from $infile: $!.\n"; | |
+ # Help files must use latin1 or utf-8 encoding. (:help help-translated) | |
+ my $encoding = scalar(<IN>) =~ /[^\x00-\x7F]/ ? 'utf-8' : 'latin1'; | |
+ seek IN, 0, 0; | |
($outfile = $infile) =~ s:.*/::g; | |
- $outfile =~ s/\.txt$//g; | |
+ $outfile =~ s/\.(?:txt|..x)$//g; | |
open( OUT, ">$outfile.html" ) | |
|| die "Couldn't write to $outfile.html: $!.\n"; | |
@@ -88,6 +91,7 @@ | |
<html> | |
<head> | |
<title>VIM: $outfile</title> | |
+<meta http-equiv="Content-Type" content="text/html; charset=$encoding"> | |
<link rel="stylesheet" href="vim-stylesheet.css" type="text/css"> | |
</head> | |
<body> |
in revision 2(69c2bdd), I have changed like the followings:
- Process *.??x files (non-English vim help files) not only *.txt files
- Add charset tag
- $encoding = "latin1" by default
- If the firstline of help file contains non-ASCII character, set "utf-8" to $encoding
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This patch does:
*.??x
files (non-English vim help files) not only*.txt
files<meta http-equiv="Content-Type" content="text/html; charset=$encoding">
$encoding = "latin1"
by default!_TAG_FILE_ENCODING
line in tags file