Skip to content

Instantly share code, notes, and snippets.

@kits
Created February 1, 2011 05:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kits/805457 to your computer and use it in GitHub Desktop.
Save kits/805457 to your computer and use it in GitHub Desktop.
pod2html の日本語ヘッダへのアンカーをWikipedia風に変更
#!/usr/bin/env perl
# pod2html の日本語ヘッダへのアンカーをWikipedia風に変更。
# 使い方は pod2html と同じ。
use strict;
use warnings;
use Pod::Html;
{
my $anchorify = sub {
my ($anchor) = @_;
$anchor = Pod::Html::htmlify($anchor);
$anchor =~ s/([\x80-\xff])/sprintf '.%02X', ord($1)/ge;
$anchor =~ s/[^0-9A-Za-z_:.-]/_/g;
return $anchor;
};
no warnings 'redefine';
*Pod::Html::anchorify = $anchorify;
}
pod2html(@ARGV);
# =head1 日本語aaです
# ↓
# <h1><a name=".E6.97.A5.E6.9C.AC.E8.AA.9Eaa.E3.81.A7.E3.81.99">日本語aaです</a></h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment