diff options
author | psyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet> | 1984-04-04 00:44:11 +0000 |
---|---|---|
committer | psyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet> | 1984-04-04 00:44:11 +0000 |
commit | 95d350614aa717e35388a7a6d1463fe8f6cf6c4e (patch) | |
tree | 2ad9731211be365f0a27ff30f2da19d3fb1da021 | |
parent | d8d58565487e9db8f996f028450e2327dbbc6661 (diff) | |
download | prep-95d350614aa717e35388a7a6d1463fe8f6cf6c4e.tar.gz prep-95d350614aa717e35388a7a6d1463fe8f6cf6c4e.zip |
smarter auto-paragraph mode
-rw-r--r-- | lib/prep/html/util.pl | 13 | ||||
-rw-r--r-- | lib/prep/prep.pl | 23 |
2 files changed, 28 insertions, 8 deletions
diff --git a/lib/prep/html/util.pl b/lib/prep/html/util.pl index 4054953..36a692a 100644 --- a/lib/prep/html/util.pl +++ b/lib/prep/html/util.pl | |||
@@ -133,8 +133,10 @@ sub do_ref { | |||
133 | sub do_sidebutton { | 133 | sub do_sidebutton { |
134 | my ($url, $name) = @_; | 134 | my ($url, $name) = @_; |
135 | $name = $url unless $name; | 135 | $name = $url unless $name; |
136 | # if you wonder why this code isn't producing | ||
137 | # any output, you probably forgot #pragma or | ||
136 | die "You forgot a comma in the $url ref!" if $url =~ / /; | 138 | die "You forgot a comma in the $url ref!" if $url =~ / /; |
137 | return '<div class="but"><a href="'. $url .'">['. $name .']</a></div>'; | 139 | return '<div class="but"><a href="'. $url .'">['. $name .']</a></div>'."\n"; |
138 | } | 140 | } |
139 | 141 | ||
140 | sub do_tag { | 142 | sub do_tag { |
@@ -181,18 +183,18 @@ sub do_numbered_item { | |||
181 | my $tx = shift; | 183 | my $tx = shift; |
182 | if ($tx eq '-') { | 184 | if ($tx eq '-') { |
183 | $LIST = 0; | 185 | $LIST = 0; |
184 | return do_li_end. "</ol>\n"; | 186 | return do_li_end. "\n</ol>\n"; |
185 | } | 187 | } |
186 | my $rc = $LIST++ ? do_li_end : "<ol>\n"; | 188 | my $rc = $LIST++ ? do_li_end : "<ol>"; |
187 | return $rc. do_li_start. $tx; | 189 | return $rc. do_li_start. $tx; |
188 | } | 190 | } |
189 | sub do_item { | 191 | sub do_item { |
190 | my $tx = shift; | 192 | my $tx = shift; |
191 | if ($tx eq '-') { | 193 | if ($tx eq '-') { |
192 | $LIST = 0; | 194 | $LIST = 0; |
193 | return do_li_end. "</ul>\n"; | 195 | return do_li_end. "\n</ul>\n"; |
194 | } | 196 | } |
195 | my $rc = $LIST++ ? do_li_end : "<ul>\n"; | 197 | my $rc = $LIST++ ? do_li_end : "<ul>"; |
196 | return $rc. do_li_start. $tx; | 198 | return $rc. do_li_start. $tx; |
197 | } | 199 | } |
198 | 200 | ||
@@ -204,4 +206,5 @@ sub do_fullscreen_off { print <<X; } | |||
204 | X | 206 | X |
205 | 207 | ||
206 | do_reset_numbers; | 208 | do_reset_numbers; |
209 | |||
207 | 1; | 210 | 1; |
diff --git a/lib/prep/prep.pl b/lib/prep/prep.pl index df40550..ce01f90 100644 --- a/lib/prep/prep.pl +++ b/lib/prep/prep.pl | |||
@@ -37,6 +37,7 @@ $block = 0; | |||
37 | $level = 0; | 37 | $level = 0; |
38 | 38 | ||
39 | $keephash = 0; | 39 | $keephash = 0; |
40 | my @out; | ||
40 | 41 | ||
41 | ## PUBLIC FUNCTIONS | 42 | ## PUBLIC FUNCTIONS |
42 | 43 | ||
@@ -70,11 +71,22 @@ sub run { | |||
70 | } else { | 71 | } else { |
71 | &include($FILE_NAME); | 72 | &include($FILE_NAME); |
72 | } | 73 | } |
74 | if (&flag('p')) { # auto-paragraph mode works better *after* rendering | ||
75 | $_ = join("", @out); | ||
76 | # but it is necessary to make style sheets resistant to this: | ||
77 | s/\n\s*\n([^\<\>\-\n])/\n<p class="text">\n\1/g; | ||
78 | print; | ||
79 | } else { | ||
80 | print join("", @out); | ||
81 | } | ||
82 | # should change this to return instead of print.. FIXME | ||
73 | &done if defined &done; | 83 | &done if defined &done; |
74 | } | 84 | } |
75 | 85 | ||
76 | ## END OF PUBLIC FUNCTIONS | 86 | ## END OF PUBLIC FUNCTIONS |
77 | 87 | ||
88 | sub out { push(@out, @_); } | ||
89 | |||
78 | sub init { | 90 | sub init { |
79 | local($a) = @_; | 91 | local($a) = @_; |
80 | undef %FLAGS; | 92 | undef %FLAGS; |
@@ -132,7 +144,7 @@ sub prep { | |||
132 | # the config. nasty! so no more leading spaces. | 144 | # the config. nasty! so no more leading spaces. |
133 | if ( not $keephash and /^#(\w+)\s*(.*?)\s*$/ ) { | 145 | if ( not $keephash and /^#(\w+)\s*(.*?)\s*$/ ) { |
134 | my $i = &interpret($1, $2); | 146 | my $i = &interpret($1, $2); |
135 | print $i if $i and length($i) > 2; # careful conversion | 147 | &out($i) if $i and length($i) > 2; # careful conversion |
136 | } | 148 | } |
137 | } | 149 | } |
138 | return unless $keephash; | 150 | return unless $keephash; |
@@ -146,7 +158,7 @@ sub prep { | |||
146 | s/\(\(\(\s*(\w+)\s*(.*?)\s*\)\)\)/&interpret($1, $2)/ge; | 158 | s/\(\(\(\s*(\w+)\s*(.*?)\s*\)\)\)/&interpret($1, $2)/ge; |
147 | 159 | ||
148 | print STDERR $_, $nl if DEBUG & 32; | 160 | print STDERR $_, $nl if DEBUG & 32; |
149 | print $_, $nl; | 161 | &out($_.$nl); |
150 | } | 162 | } |
151 | } | 163 | } |
152 | 164 | ||
@@ -255,10 +267,15 @@ sub prepdata { | |||
255 | s/ -- / — /g; # convert 0x96 into Gedankenstrich | 267 | s/ -- / — /g; # convert 0x96 into Gedankenstrich |
256 | s/�/"/g; # funky kind of quote (not “) | 268 | s/�/"/g; # funky kind of quote (not “) |
257 | s/\\u([0-9A-Fa-f]{4})/&#x\1;/g; # unicode as is | 269 | s/\\u([0-9A-Fa-f]{4})/&#x\1;/g; # unicode as is |
270 | # | ||
271 | # A systemic problem with the auto-para mode: It | ||
272 | # cannot recognize the 'X)' language syntax! A | ||
273 | # work-around is to put # in empty lines... | ||
274 | # | ||
258 | # first-upper style | 275 | # first-upper style |
259 | # s/\n\s*\n([^\n\<\>#\&])/\n<p class="text"><big>\1<\/big>/g; | 276 | # s/\n\s*\n([^\n\<\>#\&])/\n<p class="text"><big>\1<\/big>/g; |
260 | # s/\n\s*\n([^\<\>#])/\n<p class="text">\n\1<\/p>/g; | 277 | # s/\n\s*\n([^\<\>#])/\n<p class="text">\n\1<\/p>/g; |
261 | s/\n\s*\n([^\<\>#])/\n<p class="text">\n\1/g; | 278 | # s/\n\s*\n([^\<\>#\(\)])/\n<p class="text">\n\1/g; |
262 | #s/\n\s*\n([^\<\>#])/\n\n<p class="text">\n\1/g; | 279 | #s/\n\s*\n([^\<\>#])/\n\n<p class="text">\n\1/g; |
263 | # we need to do this *after* autoparagraph logic! | 280 | # we need to do this *after* autoparagraph logic! |
264 | s/^\s+\b//; # remove leading whitespace | 281 | s/^\s+\b//; # remove leading whitespace |