NAME
HTML::Rebase - rewrite HTML links to be relative to a given URL
SYNOPSIS
use HTML::Rebase qw(rebase_html rebase_css);
my $html = <<HTML;
<html>
<head>
</head>
<body>
</body>
</html>
HTML
print $local_html;
__END__
<html>
<head>
<link rel="stylesheet" src="../css/site.css" />
</head>
<body>
<a href="../index.html">Go to home page/a>
</body>
</html>
rebase_html
Rewrites all HTML links to be relative to the given URL. This only
rewrites things that look like src= and href= attributes. Unquoted
attributes will not be rewritten. This should be fixed.
rebase_css
Rewrites all CSS links to be relative to the given URL. This only
rewrites things that look like url( ... ) .
CAVEATS
Does not handle <base> tags
If the HTML contains a <base> tag, it's href= attribute is not
inspected but simply rewritten. Ideally, the href= attribute should be
identical to the URL passed to rebase_html.
Uses regular expressions to do all parsing
Instead of parsing the HTML into a DOM, performing the modifications
and then writing the DOM back out, this module uses a simplicistic
regular expressions to recognize href= and src= attributes and to
rewrite them.
REPOSITORY
The public repository of this module is
SUPPORT
BUG TRACKER
Please report bugs in this module via the RT CPAN bug queue at
mail to html-rebase-Bugs@rt.cpan.org.
AUTHOR
Max Maischein corion@cpan.org
COPYRIGHT (c)
Copyright 2015 by Max Maischein corion@cpan.org.
LICENSE
This module is released under the same terms as Perl itself.