Fossil SCM
Cleanup the double-click source display for Pikchr.
Commit
5634dfeb2f8197a0dfc50170c39e299228f75bd8d2c8e3687b33c96af5a31ead
Parent
ebf5b595704788c…
1 file changed
+5
-47
+5
-47
| --- src/markdown_html.c | ||
| +++ src/markdown_html.c | ||
| @@ -333,52 +333,10 @@ | ||
| 333 | 333 | } |
| 334 | 334 | BLOB_APPEND_LITERAL(ob, "</a>"); |
| 335 | 335 | return 1; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | -#if 0 | |
| 339 | -/* | |
| 340 | -** The nSrc bytes at zSrc[] are Pikchr input text (allegedly). Process that | |
| 341 | -** text and insert the result in place of the original. | |
| 342 | -*/ | |
| 343 | -void pikchr_to_html( | |
| 344 | - Blob *ob, /* Write the generated SVG here */ | |
| 345 | - const char *zSrc, int nSrc, /* The Pikchr source text */ | |
| 346 | - const char *zArg, int nArg /* Addition arguments */ | |
| 347 | -){ | |
| 348 | - int pikFlags = PIKCHR_PROCESS_NONCE | |
| 349 | - | PIKCHR_PROCESS_DIV | |
| 350 | - | PIKCHR_PROCESS_SRC_HIDDEN; | |
| 351 | - Blob bSrc = empty_blob; | |
| 352 | - | |
| 353 | - while( nArg>0 ){ | |
| 354 | - int i; | |
| 355 | - for(i=0; i<nArg && !fossil_isspace(zArg[i]); i++){} | |
| 356 | - if( i==6 && strncmp(zArg, "center", 6)==0 ){ | |
| 357 | - pikFlags |= PIKCHR_PROCESS_DIV_CENTER; | |
| 358 | - break; | |
| 359 | - }else if( i==6 && strncmp(zArg, "indent", 6)==0 ){ | |
| 360 | - pikFlags |= PIKCHR_PROCESS_DIV_INDENT; | |
| 361 | - break; | |
| 362 | - }else if( i==10 && strncmp(zArg, "float-left", 10)==0 ){ | |
| 363 | - pikFlags |= PIKCHR_PROCESS_DIV_FLOAT_LEFT; | |
| 364 | - break; | |
| 365 | - }else if( i==11 && strncmp(zArg, "float-right", 11)==0 ){ | |
| 366 | - pikFlags |= PIKCHR_PROCESS_DIV_FLOAT_RIGHT; | |
| 367 | - break; | |
| 368 | - } | |
| 369 | - while( i<nArg && fossil_isspace(zArg[i]) ){ i++; } | |
| 370 | - zArg += i; | |
| 371 | - nArg -= i; | |
| 372 | - } | |
| 373 | - blob_append(&bSrc, zSrc, nSrc) | |
| 374 | - /*have to dupe input to ensure a NUL-terminated source string */; | |
| 375 | - pikchr_process(blob_str(&bSrc), pikFlags, 0, ob); | |
| 376 | - blob_reset(&bSrc); | |
| 377 | -} | |
| 378 | -#endif | |
| 379 | - | |
| 380 | 338 | /* |
| 381 | 339 | ** The nSrc bytes at zSrc[] are Pikchr input text (allegedly). Process that |
| 382 | 340 | ** text and insert the result in place of the original. |
| 383 | 341 | */ |
| 384 | 342 | void pikchr_to_html( |
| @@ -386,11 +344,11 @@ | ||
| 386 | 344 | const char *zSrc, int nSrc, /* The Pikchr source text */ |
| 387 | 345 | const char *zArg, int nArg /* Addition arguments */ |
| 388 | 346 | ){ |
| 389 | 347 | int w = 0, h = 0; |
| 390 | 348 | char *zIn = fossil_strndup(zSrc, nSrc); |
| 391 | - char *zOut = pikchr(zIn, "pikchr", PIKCHR_INCLUDE_SOURCE, &w, &h); | |
| 349 | + char *zOut = pikchr(zIn, "pikchr", 0, &w, &h); | |
| 392 | 350 | if( w>0 && h>0 ){ |
| 393 | 351 | static int nSvg = 0; |
| 394 | 352 | const char *zSafeNonce = safe_html_nonce(1); |
| 395 | 353 | Blob css; |
| 396 | 354 | blob_init(&css,0,0); |
| @@ -420,18 +378,18 @@ | ||
| 420 | 378 | blob_appendf(ob, "<div id='svgid-%d'>\n", ++nSvg); |
| 421 | 379 | blob_appendf(ob, "<div class='pikchr-svg' style='%s'>\n", blob_str(&css)); |
| 422 | 380 | blob_append(ob, zOut, -1); |
| 423 | 381 | blob_appendf(ob, "</div>\n"); |
| 424 | 382 | blob_reset(&css); |
| 425 | - blob_appendf(ob, "<pre class='pikchr-src' style='display:none;'>" | |
| 426 | - "%s</pre>\n", zIn); | |
| 383 | + blob_appendf(ob, "<pre style='display:none;'><code>" | |
| 384 | + "%s</code></pre>\n", zIn); | |
| 427 | 385 | blob_appendf(ob, "</div>\n"); |
| 428 | 386 | blob_appendf(ob, |
| 429 | 387 | "<script nonce='%s'>\n" |
| 430 | 388 | "document.getElementById('svgid-%d').ondblclick=function(){\n" |
| 431 | - " for(var c of this.children){" | |
| 432 | - " c.style.display = c.style.display=='none'?'block':'none';" | |
| 389 | + " for(var c of this.children){\n" | |
| 390 | + " c.style.display = c.style.display=='none'?'block':'none';\n" | |
| 433 | 391 | " }\n" |
| 434 | 392 | "}\n" |
| 435 | 393 | "</script>\n", |
| 436 | 394 | style_nonce(), nSvg); |
| 437 | 395 | blob_appendf(ob, "%s\n", zSafeNonce); |
| 438 | 396 |
| --- src/markdown_html.c | |
| +++ src/markdown_html.c | |
| @@ -333,52 +333,10 @@ | |
| 333 | } |
| 334 | BLOB_APPEND_LITERAL(ob, "</a>"); |
| 335 | return 1; |
| 336 | } |
| 337 | |
| 338 | #if 0 |
| 339 | /* |
| 340 | ** The nSrc bytes at zSrc[] are Pikchr input text (allegedly). Process that |
| 341 | ** text and insert the result in place of the original. |
| 342 | */ |
| 343 | void pikchr_to_html( |
| 344 | Blob *ob, /* Write the generated SVG here */ |
| 345 | const char *zSrc, int nSrc, /* The Pikchr source text */ |
| 346 | const char *zArg, int nArg /* Addition arguments */ |
| 347 | ){ |
| 348 | int pikFlags = PIKCHR_PROCESS_NONCE |
| 349 | | PIKCHR_PROCESS_DIV |
| 350 | | PIKCHR_PROCESS_SRC_HIDDEN; |
| 351 | Blob bSrc = empty_blob; |
| 352 | |
| 353 | while( nArg>0 ){ |
| 354 | int i; |
| 355 | for(i=0; i<nArg && !fossil_isspace(zArg[i]); i++){} |
| 356 | if( i==6 && strncmp(zArg, "center", 6)==0 ){ |
| 357 | pikFlags |= PIKCHR_PROCESS_DIV_CENTER; |
| 358 | break; |
| 359 | }else if( i==6 && strncmp(zArg, "indent", 6)==0 ){ |
| 360 | pikFlags |= PIKCHR_PROCESS_DIV_INDENT; |
| 361 | break; |
| 362 | }else if( i==10 && strncmp(zArg, "float-left", 10)==0 ){ |
| 363 | pikFlags |= PIKCHR_PROCESS_DIV_FLOAT_LEFT; |
| 364 | break; |
| 365 | }else if( i==11 && strncmp(zArg, "float-right", 11)==0 ){ |
| 366 | pikFlags |= PIKCHR_PROCESS_DIV_FLOAT_RIGHT; |
| 367 | break; |
| 368 | } |
| 369 | while( i<nArg && fossil_isspace(zArg[i]) ){ i++; } |
| 370 | zArg += i; |
| 371 | nArg -= i; |
| 372 | } |
| 373 | blob_append(&bSrc, zSrc, nSrc) |
| 374 | /*have to dupe input to ensure a NUL-terminated source string */; |
| 375 | pikchr_process(blob_str(&bSrc), pikFlags, 0, ob); |
| 376 | blob_reset(&bSrc); |
| 377 | } |
| 378 | #endif |
| 379 | |
| 380 | /* |
| 381 | ** The nSrc bytes at zSrc[] are Pikchr input text (allegedly). Process that |
| 382 | ** text and insert the result in place of the original. |
| 383 | */ |
| 384 | void pikchr_to_html( |
| @@ -386,11 +344,11 @@ | |
| 386 | const char *zSrc, int nSrc, /* The Pikchr source text */ |
| 387 | const char *zArg, int nArg /* Addition arguments */ |
| 388 | ){ |
| 389 | int w = 0, h = 0; |
| 390 | char *zIn = fossil_strndup(zSrc, nSrc); |
| 391 | char *zOut = pikchr(zIn, "pikchr", PIKCHR_INCLUDE_SOURCE, &w, &h); |
| 392 | if( w>0 && h>0 ){ |
| 393 | static int nSvg = 0; |
| 394 | const char *zSafeNonce = safe_html_nonce(1); |
| 395 | Blob css; |
| 396 | blob_init(&css,0,0); |
| @@ -420,18 +378,18 @@ | |
| 420 | blob_appendf(ob, "<div id='svgid-%d'>\n", ++nSvg); |
| 421 | blob_appendf(ob, "<div class='pikchr-svg' style='%s'>\n", blob_str(&css)); |
| 422 | blob_append(ob, zOut, -1); |
| 423 | blob_appendf(ob, "</div>\n"); |
| 424 | blob_reset(&css); |
| 425 | blob_appendf(ob, "<pre class='pikchr-src' style='display:none;'>" |
| 426 | "%s</pre>\n", zIn); |
| 427 | blob_appendf(ob, "</div>\n"); |
| 428 | blob_appendf(ob, |
| 429 | "<script nonce='%s'>\n" |
| 430 | "document.getElementById('svgid-%d').ondblclick=function(){\n" |
| 431 | " for(var c of this.children){" |
| 432 | " c.style.display = c.style.display=='none'?'block':'none';" |
| 433 | " }\n" |
| 434 | "}\n" |
| 435 | "</script>\n", |
| 436 | style_nonce(), nSvg); |
| 437 | blob_appendf(ob, "%s\n", zSafeNonce); |
| 438 |
| --- src/markdown_html.c | |
| +++ src/markdown_html.c | |
| @@ -333,52 +333,10 @@ | |
| 333 | } |
| 334 | BLOB_APPEND_LITERAL(ob, "</a>"); |
| 335 | return 1; |
| 336 | } |
| 337 | |
| 338 | /* |
| 339 | ** The nSrc bytes at zSrc[] are Pikchr input text (allegedly). Process that |
| 340 | ** text and insert the result in place of the original. |
| 341 | */ |
| 342 | void pikchr_to_html( |
| @@ -386,11 +344,11 @@ | |
| 344 | const char *zSrc, int nSrc, /* The Pikchr source text */ |
| 345 | const char *zArg, int nArg /* Addition arguments */ |
| 346 | ){ |
| 347 | int w = 0, h = 0; |
| 348 | char *zIn = fossil_strndup(zSrc, nSrc); |
| 349 | char *zOut = pikchr(zIn, "pikchr", 0, &w, &h); |
| 350 | if( w>0 && h>0 ){ |
| 351 | static int nSvg = 0; |
| 352 | const char *zSafeNonce = safe_html_nonce(1); |
| 353 | Blob css; |
| 354 | blob_init(&css,0,0); |
| @@ -420,18 +378,18 @@ | |
| 378 | blob_appendf(ob, "<div id='svgid-%d'>\n", ++nSvg); |
| 379 | blob_appendf(ob, "<div class='pikchr-svg' style='%s'>\n", blob_str(&css)); |
| 380 | blob_append(ob, zOut, -1); |
| 381 | blob_appendf(ob, "</div>\n"); |
| 382 | blob_reset(&css); |
| 383 | blob_appendf(ob, "<pre style='display:none;'><code>" |
| 384 | "%s</code></pre>\n", zIn); |
| 385 | blob_appendf(ob, "</div>\n"); |
| 386 | blob_appendf(ob, |
| 387 | "<script nonce='%s'>\n" |
| 388 | "document.getElementById('svgid-%d').ondblclick=function(){\n" |
| 389 | " for(var c of this.children){\n" |
| 390 | " c.style.display = c.style.display=='none'?'block':'none';\n" |
| 391 | " }\n" |
| 392 | "}\n" |
| 393 | "</script>\n", |
| 394 | style_nonce(), nSvg); |
| 395 | blob_appendf(ob, "%s\n", zSafeNonce); |
| 396 |