Subject: Re: Simple guide to transformations using Jade From: Norman Walsh <ndw@xxxxxxxxxx> Date: Fri, 5 Jun 1998 08:20:36 -0400 |
/ Robin Stephenson <robin.stephenson@xxxxxxxxxxxxxxx> was heard to say: | >>>>> On Fri, 5 Jun 1998 12:04:06 +0100 | >>>>> "Sebastian" == Sebastian Rahtz <s.rahtz@xxxxxxxxxxxxxx> wrote: | | Sebastian> post-process the output with an SGML/XML pretty-printer.... Fixing the output turns out to be necessary if you use <script> (or is it <style>?) tags because if you split the tag over a line, Lynx gets confused and displays a blank page. (Grumble.) Here's the Perl script I use to massage the output from Jade before posting it on my website. It doesn't do anything fancy, but it fixes the formatting... @rem = '--*-Perl-*-- @echo off perl.exe %_batchname %$ goto endofperl @rem '; require 'n:/home/nwalsh/lib/jadefix.pl'; $loadfile = shift @ARGV || die; $savefile = shift @ARGV || $loadfile; &jadefix::sgmlfix($loadfile, $savefile); __END__ :endofperl and here's jadefix.pl: package jadefix; %PREFIX = ( '</HEAD' => "\n", '</STYLE' => "\n", '<BODY' => "\n", '<DT' => "\n", '<HEAD' => "\n", '<HR' => "\n", '<META' => "\n", '<P' => "\n", '<TABLE' => "\n", '<TD' => "\n", '<TITLE' => "\n", '<TR' => "\n", ); %PSTFIX = ( '</DD' => "\n", '</DL' => "\n", '</DT' => "\n", '</P' => "\n", '</STYLE' => "\n", '</TITLE' => "\n", '<BODY' => "\n", '<HR' => "\n", '<STYLE' => "\n", ); sub sgmlfix { my($loadfile) = shift; my($savefile) = shift || $loadfile; local(*F, $_); open (F, $loadfile); read (F, $_, -s $loadfile); close (F); s/\n>/>/sg; $pre = ""; while (/<[^>]+>/s) { $pre .= $`; $tag = $&; $_ = $'; $tag =~ s/\n/ /g; $pre .= $tag; } $_ = $pre . $_; $out = ""; while (/<[^>]+>/s) { $out .= $`; $tag = $&; $_ = $'; $tag =~ /^([^\s>]+)/; $tagid = $1; $out .= $PREFIX{$tagid} . $tag . $PSTFIX{$tagid}; } $_ = $out . $_; open (F, ">$savefile"); print F "$_\n"; close (F); } 1; DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Simple guide to transformations, Sebastian Rahtz | Thread | Re: Simple guide to transformations, Jakob Fix |
Re: Simple guide to transformations, Sebastian Rahtz | Date | Re: Idiots guide to transformations, Graydon Hoare |
Month |