paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c4a0e9fd25840e3efc87f0a0b76c31fc1bf0fa80
parent f400317d1e22c877db51f8c63ccb517994afc01f
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Wed, 27 May 2020 15:51:18 -0400

Beginnings of goper conversion script

Diffstat:
Agopherize | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+), 0 deletions(-)

diff --git a/gopherize b/gopherize @@ -0,0 +1,59 @@ +#!/usr/bin/env perl + +# gopherize +# A script to convert an html document into gopher-compatible syntax +# +# Copyright (C) 2020 Jake Bauer +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +use strict; +use warnings; +our $VERSION = "0.1.0"; + +package Gopherize; +use base "HTML::Parser"; + +sub text { + my ($self, $text) = @_; + # print original text + print $text; +} + +sub comment { + my ($self, $comment) = @_; + #print original text w/ comment marker + print ""; +} + +sub start { + my ($self, $tag, $attr, $attrseq, $origtext) = @_; + #print original text + print $origtext; +} + +sub end { + my ($self, $tag, $origtext) = @_; + #print original text + print $origtext; +} + +my $parser = new HTMLStrip; + +my @files = @ARGV; + +foreach my $file (@files) { + open($file) or warn "Could not open $file"; + $parser->parse_file($file); +}