| | @@ -339,35 +339,39 @@ |
| 339 | 339 | char *zIn = fossil_strndup(zSrc, nSrc); |
| 340 | 340 | char *zOut = pikchr(zIn, "pikchr", 0, &w, &h); |
| 341 | 341 | fossil_free(zIn); |
| 342 | 342 | if( w>0 && h>0 ){ |
| 343 | 343 | const char *zNonce = safe_html_nonce(1); |
| 344 | | - char *zCss = 0; |
| 344 | + Blob css; |
| 345 | + blob_init(&css,0,0); |
| 346 | + blob_appendf(&css,"max-width:%dpx;",w); |
| 345 | 347 | blob_append(ob, zNonce, -1); |
| 346 | 348 | blob_append_char(ob, '\n'); |
| 347 | | - while( nArg>0 && zCss==0 ){ |
| 349 | + while( nArg>0 ){ |
| 348 | 350 | int i; |
| 349 | 351 | for(i=0; i<nArg && !fossil_isspace(zArg[i]); i++){} |
| 350 | 352 | if( i==6 && strncmp(zArg, "center", 6)==0 ){ |
| 351 | | - zCss = mprintf("display:block;margin:auto;width:%dpx;", w); |
| 353 | + blob_appendf(&css, "display:block;margin:auto;"); |
| 354 | + break; |
| 352 | 355 | }else if( i==6 && strncmp(zArg, "indent", 6)==0 ){ |
| 353 | | - zCss = fossil_strdup("margin-left:4em;"); |
| 356 | + blob_appendf(&css, "margin-left:4em;"); |
| 357 | + break; |
| 354 | 358 | }else if( i==10 && strncmp(zArg, "float-left", 10)==0 ){ |
| 355 | | - zCss = mprintf("float:left;width:%d;padding=4em;",w); |
| 359 | + blob_appendf(&css, "float:left;padding=4em;"); |
| 360 | + break; |
| 356 | 361 | }else if( i==11 && strncmp(zArg, "float-right", 11)==0 ){ |
| 357 | | - zCss = mprintf("float:right;width:%d;padding=4em;",w); |
| 362 | + blob_appendf(&css, "float:right;padding=4em;"); |
| 363 | + break; |
| 358 | 364 | } |
| 359 | 365 | while( i<nArg && fossil_isspace(zArg[i]) ){ i++; } |
| 360 | 366 | zArg += i; |
| 361 | 367 | nArg -= i; |
| 362 | 368 | } |
| 363 | | - if( zCss ) blob_appendf(ob, "<div style='%s'>\n", zCss); |
| 369 | + blob_appendf(ob, "<div style='%s'>\n", blob_str(&css)); |
| 364 | 370 | blob_append(ob, zOut, -1); |
| 365 | | - if( zCss ){ |
| 366 | | - blob_appendf(ob, "</div>\n"); |
| 367 | | - fossil_free(zCss); |
| 368 | | - } |
| 371 | + blob_appendf(ob, "</div>\n"); |
| 372 | + blob_reset(&css); |
| 369 | 373 | blob_appendf(ob, "%s\n", zNonce); |
| 370 | 374 | }else{ |
| 371 | 375 | blob_appendf(ob, "<pre>\n%s\n</pre>\n", zOut); |
| 372 | 376 | } |
| 373 | 377 | free(zOut); |
| 374 | 378 | |