169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
}
/*
** COMMAND: pikchr
**
** Usage: %fossil pikchr [options] ?INFILE? ?OUTFILE?
**
** Accepts a pikchr script as input and outputs the rendered
** script as an SVG graphic.
**
** Options:
**
** -div On success, adds a DIV wrapper around the
** resulting SVG output which limits its max-width.
**
** -th Process the input using TH1 before passing it to pikchr.
**
** -th-novar Disable $var and $<var> TH1 processing. Only applies
** with the -th flag. Use this if the pikchr script uses
** '$' for its own purposes.
**
** -th-nosvg When using -th, output the post-TH1'd script
** instead of the pikchr-rendered output.
**
** -th-trace Trace TH1 execution (for debugging purposes)
**
** TH1 Caveats:
**
** If the -th flag is used, this command must open a fossil database
** for certain functionality to work. It will run TH1 without opening
** a db if one cannot be found in the current checkout or with the -R
** REPO flag, but any TH1 commands which require a db will then fail.
**
** Many of the fossil-installed TH1 functions do not make any sense
** for pikchr scripts
*/
void pikchr_cmd(void){
Blob bIn = empty_blob;
Blob bOut = empty_blob;
const char * zInfile = "-";
const char * zOutfile = "-";
const int fWithDiv = find_option("div",0,0)!=0;
|
|
|
>
>
|
|
>
>
|
|
|
|
|
|
|
|
|
<
>
|
>
>
>
>
>
>
>
>
|
|
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
}
/*
** COMMAND: pikchr
**
** Usage: %fossil pikchr [options] ?INFILE? ?OUTFILE?
**
** Accepts a pikchr script as input and outputs the rendered script as
** an SVG graphic. The INFILE and OUTFILE options default to stdin
** resp. stdout, and the names "-" can be used as aliases for those
** streams.
**
** Options:
**
** -div On success, adds a DIV wrapper around the
** resulting SVG output which limits its max-width to
** its computed maximum ideal size, in order to mimic
** how fossil's web-based components work.
**
** -th Process the input using TH1 before passing it to pikchr.
**
** -th-novar Disable $var and $<var> TH1 processing. Use this if the
** pikchr script uses '$' for its own purposes and that
** causes
**
** -th-nosvg When using -th, output the post-TH1'd script
** instead of the pikchr-rendered output.
**
** -th-trace Trace TH1 execution (for debugging purposes).
**
** TH1-related Notes and Caveats:
**
** If the -th flag is used, this command must open a fossil database
** for certain functionality to work (via a checkout or the -R REPO
** flag). If opening a db fails, execution will continue but any TH1
** commands which require a db will trigger a fatal error.
**
** In Fossil skins, TH1 vars in the form $x are expanded as-is and
** those in the form $<x> are htmlized in the resulting output. This
** processor disables the htmlizing step, so $x and $<x> are
** equivalent UNLESS the TH1-processed pikchr script invokes the TH1
** enable_htmlify command to enable it. Normally that option will
** interfere with pikchr output, however, e.g. by HTML-encoding
** double-quotes.
**
** Many of the fossil-installed TH1 functions simply do not make any
** sense for pikchr scripts
*/
void pikchr_cmd(void){
Blob bIn = empty_blob;
Blob bOut = empty_blob;
const char * zInfile = "-";
const char * zOutfile = "-";
const int fWithDiv = find_option("div",0,0)!=0;
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
if(fWithDiv){
blob_appendf(&bOut,"<div style='max-width:%dpx;'>\n", w);
}
blob_append(&bOut, zOut, -1);
if(fWithDiv){
blob_append(&bOut,"</div>\n", 7);
}
}else{
isErr = 2;
blob_append(&bOut, zOut, -1);
}
fossil_free(zOut);
}
}
if(isErr){
/*fossil_print("ERROR: raw input:\n%b\n", &bIn);*/
fossil_fatal("%s ERROR: %b", 1==isErr ? "TH1" : "pikchr",
&bOut);
}else{
blob_write_to_file(&bOut, zOutfile);
}
Th_PrintTraceLog();
blob_reset(&bIn);
blob_reset(&bOut);
}
|
>
|
<
|
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
if(fWithDiv){
blob_appendf(&bOut,"<div style='max-width:%dpx;'>\n", w);
}
blob_append(&bOut, zOut, -1);
if(fWithDiv){
blob_append(&bOut,"</div>\n", 7);
}
fossil_free(zOut);
}else{
isErr = 2;
blob_set_dynamic(&bOut, zOut);
}
}
}
if(isErr){
/*fossil_print("ERROR: raw input:\n%b\n", &bIn);*/
fossil_fatal("%s ERROR: %b", 1==isErr ? "TH1" : "pikchr",
&bOut);
}else{
blob_write_to_file(&bOut, zOutfile);
}
Th_PrintTraceLog();
blob_reset(&bIn);
blob_reset(&bOut);
}
|