aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpsyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet>1984-04-04 00:44:15 +0000
committerpsyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet>1984-04-04 00:44:15 +0000
commit9a7519e4181239735389d5818c30826f3a06a11d (patch)
tree1640b02649a19ffd542fd01050921aca7315f0c7
parent5a8f690ec5feb72d25803435abd52f818e5ed11a (diff)
downloadprep-9a7519e4181239735389d5818c30826f3a06a11d.tar.gz
prep-9a7519e4181239735389d5818c30826f3a06a11d.zip
stricter on syntax
-rw-r--r--lib/prep/prep.pl23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/prep/prep.pl b/lib/prep/prep.pl
index ce01f90..efe08d1 100644
--- a/lib/prep/prep.pl
+++ b/lib/prep/prep.pl
@@ -48,6 +48,7 @@ sub run {
48 %VAR = @_; 48 %VAR = @_;
49 49
50 &init($FLAGS) if $FLAGS; 50 &init($FLAGS) if $FLAGS;
51 # this could use a generalized redo to handle more languages
51 &define('E') if $FILE_NAME =~ /\.(en)\./i; 52 &define('E') if $FILE_NAME =~ /\.(en)\./i;
52 &define('D') if $FILE_NAME =~ /\.(de)\./i; 53 &define('D') if $FILE_NAME =~ /\.(de)\./i;
53 &define('F') if $FILE_NAME =~ /\.(fr)\./i; 54 &define('F') if $FILE_NAME =~ /\.(fr)\./i;
@@ -60,21 +61,19 @@ sub run {
60 $LANGUAGE = 'it' if &flag('I'); 61 $LANGUAGE = 'it' if &flag('I');
61 $LANGUAGE = 'es' if &flag('S'); 62 $LANGUAGE = 'es' if &flag('S');
62 63
63 # other popular flags: 64 # should change this to return instead of print.. FIXME
64 # N - netscape only
65 # X - exploder only
66 # P - print edition
67
68 &doing if defined &doing; 65 &doing if defined &doing;
69 if ($rawdata) { 66 if ($rawdata) {
70 &prepdata($rawdata); 67 &prepdata($rawdata);
71 } else { 68 } else {
72 &include($FILE_NAME); 69 &include($FILE_NAME);
73 } 70 }
74 if (&flag('p')) { # auto-paragraph mode works better *after* rendering 71 # auto-paragraph mode works better *after* rendering
72 if (&flag('p')) {
75 $_ = join("", @out); 73 $_ = join("", @out);
76 # but it is necessary to make style sheets resistant to this: 74 # but it is necessary to make style sheets resistant to this:
77 s/\n\s*\n([^\<\>\-\n])/\n<p class="text">\n\1/g; 75 s/\n\s*\n([^\<\>\-\n])/\n<p class="text">\n\1/g;
76 # best if they are kept in external css files
78 print; 77 print;
79 } else { 78 } else {
80 print join("", @out); 79 print join("", @out);
@@ -100,6 +99,7 @@ sub prep {
100 study; 99 study;
101 s/\r?\n?$//; # remove line delimiters 100 s/\r?\n?$//; # remove line delimiters
102 101
102 # make this conditional.. this syntax is very nerdy
103 if (/(.*)\\$/o) { # support for \ line merging 103 if (/(.*)\\$/o) { # support for \ line merging
104 $nl = ''; 104 $nl = '';
105 $_ = $1; 105 $_ = $1;
@@ -107,6 +107,7 @@ sub prep {
107 $nl = "\n"; 107 $nl = "\n";
108 } 108 }
109 109
110 # make this conditional.. this syntax can be invasive
110 ($pre, $post) = /^([A-Z]+)\)(.*)/o; # support for flag) syntax 111 ($pre, $post) = /^([A-Z]+)\)(.*)/o; # support for flag) syntax
111 if ($pre) { 112 if ($pre) {
112 local($state) = 0; 113 local($state) = 0;
@@ -121,6 +122,7 @@ sub prep {
121 } 122 }
122 123
123 # support for leading # 124 # support for leading #
125 # make this optional.. leading caret isn't always ideal
124 if (/^#/) { 126 if (/^#/) {
125 return if /^##/; # psyced style comments 127 return if /^##/; # psyced style comments
126 print STDERR "parsing $_\n" if DEBUG & 2; 128 print STDERR "parsing $_\n" if DEBUG & 2;
@@ -146,6 +148,10 @@ sub prep {
146 my $i = &interpret($1, $2); 148 my $i = &interpret($1, $2);
147 &out($i) if $i and length($i) > 2; # careful conversion 149 &out($i) if $i and length($i) > 2; # careful conversion
148 } 150 }
151 else {
152 return if $_ eq '#' or /^#\s/;
153 print STDERR "warning: '$_'\n";# if $VAR{strict};
154 }
149 } 155 }
150 return unless $keephash; 156 return unless $keephash;
151 } 157 }
@@ -294,7 +300,10 @@ sub interpret {
294 } 300 }
295 301
296 my $func = "do_$cmd"; 302 my $func = "do_$cmd";
297 return unless defined &$func; 303 unless (defined &$func) {
304 die "unrecognized $cmd directive";
305 return;
306 }
298 my $ret; 307 my $ret;
299 308
300 @A = split(/\s+\,\s+/, $args); 309 @A = split(/\s+\,\s+/, $args);