1#!/usr/bin/env perl 2# vim:ts=4:sw=4:expandtab 3 4use strict; 5use warnings; 6use Pod::Simple::HTML; 7use Getopt::Long; 8use v5.10; 9 10my $stylesurl = ''; 11 12GetOptions("stylesurl=s" => \$stylesurl) 13 or die "parsing flags"; 14 15$Pod::Simple::HTML::Tagmap{'Verbatim'} = '<pre><tt>'; 16$Pod::Simple::HTML::Tagmap{'VerbatimFormatted'} = '<pre><tt>'; 17$Pod::Simple::HTML::Tagmap{'/Verbatim'} = '</tt></pre>'; 18$Pod::Simple::HTML::Tagmap{'/VerbatimFormatted'} = '</tt></pre>'; 19 20if (@ARGV < 2) { 21 say STDERR "Syntax: i3-pod2html <pod-input-path> <html-output-path>"; 22 exit 1; 23} 24 25open(my $in, '<', $ARGV[0]) or die "Couldn’t open $ARGV[0] for reading: $!\n"; 26open(my $out, '>', $ARGV[1]) or die "Couldn’t open $ARGV[1] for writing: $!\n"; 27 28my $parser = Pod::Simple::HTML->new(); 29 30$parser->index(1); 31if ($stylesurl ne '') { 32 $parser->html_header_before_title( 33<<EOF 34<!doctype html> 35<html lang="en"> 36<head> 37<link rel="icon" type="image/png" href="/favicon.png"> 38<meta charset="utf-8"> 39<meta name="generator" content="Pod::Simple::HTML"> 40<meta name="description" content="i3 Perl documentation"> 41<link rel="stylesheet" href="$stylesurl/style.css" type="text/css" /> 42<style type="text/css"> 43.pod pre { 44 background: #333; 45 border: 1px solid #555; 46 border-left: 5px solid #555; 47 padding: 0.5em; 48 padding-left: 0; 49 padding-right: 0.5em; 50 white-space: pre; 51 color: white; 52} 53 54.pod ul { 55 list-style-type: none; 56} 57.pod li { 58 margin-bottom: 0 !important; 59} 60 61tt { 62 font-family: 'Droid Sans Mono', sans-serif; 63 font-size: inherit; 64} 65 66.pod h1 a, .pod h2 a, .pod h3 a, .pod h4 a { 67 text-decoration: none; 68 color: white; 69} 70</style> 71<title> 72EOF 73 ); 74} 75$parser->html_header_after_title( 76<<'EOF' 77</title> 78</head> 79<body> 80 81 <div id="main"> 82 <a href="/"><h1 id="title">i3 - improved tiling WM</h1></a> 83 <ul id="nav"> 84 <li><a style="border-bottom: 2px solid #fff" href="/docs">Docs</a></li> 85 <li><a href="/screenshots">Screens</a></li> 86 <li><a href="https://www.github.com/i3/i3/discussions">Get Help</a></li> 87 <li><a href="/contact">Contact</a></li> 88 <li><a href="https://bugs.i3wm.org/">Bugs</a></li> 89 </ul> 90 <br style="clear: both"> 91<div id="content" class="pod"> 92<h1>i3 Perl documentation</h1> 93 94EOF 95); 96 97$parser->output_fh($out); 98$parser->parse_file($in); 99