#!/usr/local/bin/perl # Extract entries from the CSS properties database # The database has the following format: # name;; values;; initial-value;; applies-to;; # inherited;; percentages;; media;; # Special characters: # 1) Translate "*" into the words "all elements" # 1.a) Translate "XX" into "not defined for shorthand properties" # 2) "" means the value is defined elsewhere. Translate to # <name> # 3) "<'name'>" means the set of values is the same as for the # property with the same name. Translate to # <'name'> # # Ian Jacobs - ij@w3.org (Based on work by Arnaud Le Hors) # $Id: pextr,v 1.6 1997-12-16 20:51:56 ijacobs Exp $ $PROGNAME = substr($0, rindex($0, "/") + 1); if (!$ARGV[0]) { print "Usage: $PROGNAME file [tgt_dir]\n"; exit 1; } # copy file in memory if (!open(input, $ARGV[0])) { print "$PROGNAME Error: Cannot open file: $ARGV[0]\n"; exit 1; } $buf = ""; while () { $buf .= $_; } close(input); $path = ""; if ($ARGV[1]) { $path = "$ARGV[1]/"; } # regexps $sp = "[ \t\n]*"; # whitespace $patt = "$sp(.*?)$sp"; $blockst = "[/][*]"; $blocket = "[*][/]"; sub format_property { $name = $_[0]; $values = $_[1]; $init = $_[2]; $applies = $_[3]; $inherited = $_[4]; $percentages = $_[5]; $media = $_[6]; #Do next three lines in src files to get headings right. print output "
\n"; print output "

'$name'

\n"; print output "\n"; &format_name($name); &format_values($values); &format_init($init); &format_applies($applies); &format_inherited($inherited); &format_percentages($percentages); &format_media($media); print output "
\n"; print output "
\n\n"; } sub format_name { print output "Property name:"; print output "\'$_[0]\'\n"; } sub format_values { $values = $_[0]; $values =~ s/<([^>']*)>/<$1><\/span>/g; $values =~ s/<[']([^']*)[']>/<'$1'><\/span>/g; print output "Value:$values\n"; } sub format_init { #Note that in the case of properties, <> are removed in text. $init = $_[0]; $init =~ s/XX/not defined for shorthand properties/g; $init =~ s/<([^>']*)>/<$1><\/span>/g; $init =~ s/<[']([^']*)[']>/'$1'<\/span>/g; print output "Initial:$init\n"; } sub format_applies { #Note that in the case of properties, <> are removed in text. $applies = $_[0]; $applies =~ s/\*/all elements/g; $applies =~ s/<([^>']*)>/<$1><\/span>/g; $applies =~ s/<[']([^']*)[']>/'$1'<\/span>/g; print output "Applies to:$applies\n"; } sub format_inherited { print output "Inherited:$_[0]\n"; } sub format_percentages { #Note that in the case of properties, <> are removed in text. $perc = $_[0]; $perc =~ s/<([^>']*)>/<$1><\/span>/g; $perc =~ s/<[']([^']*)[']>/'$1'<\/span>/g; print output "Percentage values:$perc\n"; } sub format_media { $fmedia = $_[0]; $fmedia =~ s/p_c/p_c<\/a>/; $fmedia =~ s/g_b/g_b<\/a>/; $fmedia =~ s/v_a_t/v_a_t<\/a>/; $fmedia =~ s/visual/visual<\/a>/; $fmedia =~ s/aural/aural<\/a>/; $fmedia =~ s/tactile/tactile<\/a>/; $fmedia =~ s/continuous/continuous<\/a>/; $fmedia =~ s/paged/paged<\/a>/; $fmedia =~ s/grid/grid<\/a>/; $fmedia =~ s/all/all<\/a>/; print output "Media groups:$fmedia\n"; } # extract every possible block $_ = $buf; while (/$blockst$patt;;$patt;;$patt;;$patt;;$patt;;$patt;;$patt$blocket/s) { # Set parameters first (before any modifications) $placeholder = $'; $output = "$path$1.srb"; print "\textracting $output\n"; open(output, "> $output"); &format_property($1, $2, $3, $4, $5, $6, $7); close(output); $_ = $placeholder; }