Mercurial > hg > batmud > ggrtf
changeset 619:3ab1d39cac73
Added very simple utility for normalizing SGML/XML files, kludged in Perl.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 06 Jun 2007 02:02:14 +0000 |
parents | a097705556c5 |
children | b51e42467f2c |
files | docs/normalizeml.pl |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/normalizeml.pl Wed Jun 06 02:02:14 2007 +0000 @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w +# +# Utility for "normalizing" XML/SGML files +# Programmed by Matti 'ccr' Hamalainen +# (C) Copyright 2007 Tecnic Software productions (TNSP) +# +my %ents; +my $entMode = 0; +my $entData; +my $entName; + +while (<STDIN>) { + if (/<!ENTITY ([a-z_]+) \"([^\"]*)\">/) { + $ents{$1} = $2; + } elsif (/<!ENTITY ([a-z_]+) \"(.*)$/) { + $entName = $1; + $entData = $2; + $entMode = 1; + } elsif ($entMode == 1) { + if (/^(.*)\">/) { + $entData .= $1; + $ents{$entName} = $entData; + $entMode = 0; + } else { + $entData .= $_; + } + } else { + my $s = $_; + while(($k, $v) = each(%ents)) { + $s =~ s/&$k;/$v/; + } + print $s; + } +}