Created
December 3, 2015 15:22
-
-
Save lmmx/bc83cf85af86e589e9d4 to your computer and use it in GitHub Desktop.
OPML to HTML bookmarks file converter, via http://jeremy.zawodny.com/blog/archives/000386.html
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
#!/usr/bin/perl -w | |
# | |
# opml2html.pl, (c) Jeremy Zawodny -- http://jerermy.zawodny.com/blog/ | |
# | |
# Updated by Michael Radwin (http://www.radwin.org/michael/blog/) | |
# on Dec 26th, 2003 to include image size attributes and link | |
# titles. | |
# | |
# You may distribute this code freely. It's not rocket science. | |
# | |
# Given an OPML file on stdin, produces an XHTML "blgoroll" fragment | |
# suitable for inclusion on a weblog. Tested with AmphetaDesk and | |
# Radio UserLand. | |
# | |
# Usage: opml2html.pl < foo.opml > bar.html | |
# | |
use strict; | |
use XML::Simple; | |
use Data::Dumper; | |
use HTML::Entities; | |
my $xml; | |
{ | |
local($/) = undef; | |
$xml = <>; | |
} | |
my $info = XML::Simple::XMLin($xml); | |
my $data = $info->{body}->{outline}; | |
my @list = sort { lc $a->{title} cmp lc $b->{title} } @$data; | |
for my $item (@list) | |
{ | |
my $title = encode_entities($item->{title}); | |
my $h_url = $item->{htmlurl} || $item->{htmlUrl}; | |
my $x_url = $item->{xmlurl} || $item->{xmlUrl}; | |
my $descr = encode_entities($item->{description}); | |
print qq[<p>]; | |
print qq[<a href="$x_url"><img src="xml.gif" border="0" width="36" height="14" /></a>\n]; | |
print qq[<a title="$descr" href="$h_url">$title</a></p>]; | |
print "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment