| | @@ -29,11 +29,19 @@ |
| 29 | 29 | struct Blob *output_title, |
| 30 | 30 | struct Blob *output_body); |
| 31 | 31 | |
| 32 | 32 | #endif /* INTERFACE */ |
| 33 | 33 | |
| 34 | | -typedef union { uint64_t u; char c[8]; unsigned char b[8]; } bitfield64_t; |
| 34 | +/* |
| 35 | +** Markdown-internal helper for generating unique link reference IDs. |
| 36 | +*/ |
| 37 | +typedef union bitfield64_t bitfield64_t; |
| 38 | +union bitfield64_t{ |
| 39 | + uint64_t u; |
| 40 | + char c[8]; |
| 41 | + unsigned char b[8]; |
| 42 | +}; |
| 35 | 43 | |
| 36 | 44 | /* |
| 37 | 45 | ** An instance of the following structure is passed through the |
| 38 | 46 | ** "opaque" pointer. |
| 39 | 47 | */ |
| | @@ -50,20 +58,10 @@ |
| 50 | 58 | |
| 51 | 59 | /* INTER_BLOCK -- skip a line between block level elements */ |
| 52 | 60 | #define INTER_BLOCK(ob) \ |
| 53 | 61 | do { if( blob_size(ob)>0 ) blob_append_char(ob, '\n'); } while (0) |
| 54 | 62 | |
| 55 | | -/* BLOB_APPEND_LITERAL -- append a string literal to a blob |
| 56 | | -** TODO: Refactor all invocations to use global macro blob_append_literal() |
| 57 | | -*/ |
| 58 | | -#define BLOB_APPEND_LITERAL blob_append_literal |
| 59 | | - |
| 60 | | -/* BLOB_APPEND_BLOB -- append blob contents to another |
| 61 | | -** TODO: Refactor all invocations to use global macro blob_appendb() |
| 62 | | -*/ |
| 63 | | -#define BLOB_APPEND_BLOB(dest, src) blob_appendb((dest), (src)) |
| 64 | | - |
| 65 | 63 | #ifndef FOOTNOTES_WITHOUT_URI |
| 66 | 64 | #define BLOB_APPEND_URI(dest,ctx) blob_appendb(dest,&((ctx)->reqURI)) |
| 67 | 65 | #else |
| 68 | 66 | #define BLOB_APPEND_URI(dest,ctx) |
| 69 | 67 | #endif |
| | @@ -106,19 +104,19 @@ |
| 106 | 104 | i++; |
| 107 | 105 | } |
| 108 | 106 | blob_append(ob, data+beg, i-beg); |
| 109 | 107 | while( i<size ){ |
| 110 | 108 | if( data[i]=='<' ){ |
| 111 | | - BLOB_APPEND_LITERAL(ob, "<"); |
| 109 | + blob_append_literal(ob, "<"); |
| 112 | 110 | }else if( data[i]=='>' ){ |
| 113 | | - BLOB_APPEND_LITERAL(ob, ">"); |
| 111 | + blob_append_literal(ob, ">"); |
| 114 | 112 | }else if( data[i]=='&' ){ |
| 115 | | - BLOB_APPEND_LITERAL(ob, "&"); |
| 113 | + blob_append_literal(ob, "&"); |
| 116 | 114 | }else if( data[i]=='"' ){ |
| 117 | | - BLOB_APPEND_LITERAL(ob, """); |
| 115 | + blob_append_literal(ob, """); |
| 118 | 116 | }else if( data[i]=='\'' ){ |
| 119 | | - BLOB_APPEND_LITERAL(ob, "'"); |
| 117 | + blob_append_literal(ob, "'"); |
| 120 | 118 | }else{ |
| 121 | 119 | break; |
| 122 | 120 | } |
| 123 | 121 | i++; |
| 124 | 122 | } |
| | @@ -136,15 +134,15 @@ |
| 136 | 134 | i++; |
| 137 | 135 | } |
| 138 | 136 | blob_append(ob, data+beg, i-beg); |
| 139 | 137 | while( i<size ){ |
| 140 | 138 | if( data[i]=='<' ){ |
| 141 | | - BLOB_APPEND_LITERAL(ob, "<"); |
| 139 | + blob_append_literal(ob, "<"); |
| 142 | 140 | }else if( data[i]=='>' ){ |
| 143 | | - BLOB_APPEND_LITERAL(ob, ">"); |
| 141 | + blob_append_literal(ob, ">"); |
| 144 | 142 | }else if( data[i]=='&' ){ |
| 145 | | - BLOB_APPEND_LITERAL(ob, "&"); |
| 143 | + blob_append_literal(ob, "&"); |
| 146 | 144 | }else{ |
| 147 | 145 | break; |
| 148 | 146 | } |
| 149 | 147 | i++; |
| 150 | 148 | } |
| | @@ -157,17 +155,17 @@ |
| 157 | 155 | /* Size of the prolog: "<div class='markdown'>\n" */ |
| 158 | 156 | #define PROLOG_SIZE 23 |
| 159 | 157 | |
| 160 | 158 | static void html_prolog(struct Blob *ob, void *opaque){ |
| 161 | 159 | INTER_BLOCK(ob); |
| 162 | | - BLOB_APPEND_LITERAL(ob, "<div class=\"markdown\">\n"); |
| 160 | + blob_append_literal(ob, "<div class=\"markdown\">\n"); |
| 163 | 161 | assert( blob_size(ob)==PROLOG_SIZE ); |
| 164 | 162 | } |
| 165 | 163 | |
| 166 | 164 | static void html_epilog(struct Blob *ob, void *opaque){ |
| 167 | 165 | INTER_BLOCK(ob); |
| 168 | | - BLOB_APPEND_LITERAL(ob, "</div>\n"); |
| 166 | + blob_append_literal(ob, "</div>\n"); |
| 169 | 167 | } |
| 170 | 168 | |
| 171 | 169 | static void html_blockhtml(struct Blob *ob, struct Blob *text, void *opaque){ |
| 172 | 170 | char *data = blob_buffer(text); |
| 173 | 171 | size_t size = blob_size(text); |
| | @@ -185,25 +183,25 @@ |
| 185 | 183 | blob_append(title, data+nTag, size - nTag - 5); |
| 186 | 184 | return; |
| 187 | 185 | } |
| 188 | 186 | INTER_BLOCK(ob); |
| 189 | 187 | blob_append(ob, data, size); |
| 190 | | - BLOB_APPEND_LITERAL(ob, "\n"); |
| 188 | + blob_append_literal(ob, "\n"); |
| 191 | 189 | } |
| 192 | 190 | |
| 193 | 191 | static void html_blockcode(struct Blob *ob, struct Blob *text, void *opaque){ |
| 194 | 192 | INTER_BLOCK(ob); |
| 195 | | - BLOB_APPEND_LITERAL(ob, "<pre><code>"); |
| 193 | + blob_append_literal(ob, "<pre><code>"); |
| 196 | 194 | html_escape(ob, blob_buffer(text), blob_size(text)); |
| 197 | | - BLOB_APPEND_LITERAL(ob, "</code></pre>\n"); |
| 195 | + blob_append_literal(ob, "</code></pre>\n"); |
| 198 | 196 | } |
| 199 | 197 | |
| 200 | 198 | static void html_blockquote(struct Blob *ob, struct Blob *text, void *opaque){ |
| 201 | 199 | INTER_BLOCK(ob); |
| 202 | | - BLOB_APPEND_LITERAL(ob, "<blockquote>\n"); |
| 203 | | - BLOB_APPEND_BLOB(ob, text); |
| 204 | | - BLOB_APPEND_LITERAL(ob, "</blockquote>\n"); |
| 200 | + blob_append_literal(ob, "<blockquote>\n"); |
| 201 | + blob_appendb(ob, text); |
| 202 | + blob_append_literal(ob, "</blockquote>\n"); |
| 205 | 203 | } |
| 206 | 204 | |
| 207 | 205 | static void html_header( |
| 208 | 206 | struct Blob *ob, |
| 209 | 207 | struct Blob *text, |
| | @@ -212,22 +210,22 @@ |
| 212 | 210 | ){ |
| 213 | 211 | struct Blob *title = ((MarkdownToHtml*)opaque)->output_title; |
| 214 | 212 | /* The first header at the beginning of a text is considered as |
| 215 | 213 | * a title and not output. */ |
| 216 | 214 | if( blob_size(ob)<=PROLOG_SIZE && title!=0 && blob_size(title)==0 ){ |
| 217 | | - BLOB_APPEND_BLOB(title, text); |
| 215 | + blob_appendb(title, text); |
| 218 | 216 | return; |
| 219 | 217 | } |
| 220 | 218 | INTER_BLOCK(ob); |
| 221 | 219 | blob_appendf(ob, "<h%d>", level); |
| 222 | | - BLOB_APPEND_BLOB(ob, text); |
| 220 | + blob_appendb(ob, text); |
| 223 | 221 | blob_appendf(ob, "</h%d>", level); |
| 224 | 222 | } |
| 225 | 223 | |
| 226 | 224 | static void html_hrule(struct Blob *ob, void *opaque){ |
| 227 | 225 | INTER_BLOCK(ob); |
| 228 | | - BLOB_APPEND_LITERAL(ob, "<hr />\n"); |
| 226 | + blob_append_literal(ob, "<hr />\n"); |
| 229 | 227 | } |
| 230 | 228 | |
| 231 | 229 | |
| 232 | 230 | static void html_list( |
| 233 | 231 | struct Blob *ob, |
| | @@ -238,11 +236,11 @@ |
| 238 | 236 | char ol[] = "ol"; |
| 239 | 237 | char ul[] = "ul"; |
| 240 | 238 | char *tag = (flags & MKD_LIST_ORDERED) ? ol : ul; |
| 241 | 239 | INTER_BLOCK(ob); |
| 242 | 240 | blob_appendf(ob, "<%s>\n", tag); |
| 243 | | - BLOB_APPEND_BLOB(ob, text); |
| 241 | + blob_appendb(ob, text); |
| 244 | 242 | blob_appendf(ob, "</%s>\n", tag); |
| 245 | 243 | } |
| 246 | 244 | |
| 247 | 245 | static void html_list_item( |
| 248 | 246 | struct Blob *ob, |
| | @@ -251,20 +249,20 @@ |
| 251 | 249 | void *opaque |
| 252 | 250 | ){ |
| 253 | 251 | char *text_data = blob_buffer(text); |
| 254 | 252 | size_t text_size = blob_size(text); |
| 255 | 253 | while( text_size>0 && text_data[text_size-1]=='\n' ) text_size--; |
| 256 | | - BLOB_APPEND_LITERAL(ob, "<li>"); |
| 254 | + blob_append_literal(ob, "<li>"); |
| 257 | 255 | blob_append(ob, text_data, text_size); |
| 258 | | - BLOB_APPEND_LITERAL(ob, "</li>\n"); |
| 256 | + blob_append_literal(ob, "</li>\n"); |
| 259 | 257 | } |
| 260 | 258 | |
| 261 | 259 | static void html_paragraph(struct Blob *ob, struct Blob *text, void *opaque){ |
| 262 | 260 | INTER_BLOCK(ob); |
| 263 | | - BLOB_APPEND_LITERAL(ob, "<p>"); |
| 264 | | - BLOB_APPEND_BLOB(ob, text); |
| 265 | | - BLOB_APPEND_LITERAL(ob, "</p>\n"); |
| 261 | + blob_append_literal(ob, "<p>"); |
| 262 | + blob_appendb(ob, text); |
| 263 | + blob_append_literal(ob, "</p>\n"); |
| 266 | 264 | } |
| 267 | 265 | |
| 268 | 266 | |
| 269 | 267 | static void html_table( |
| 270 | 268 | struct Blob *ob, |
| | @@ -271,84 +269,85 @@ |
| 271 | 269 | struct Blob *head_row, |
| 272 | 270 | struct Blob *rows, |
| 273 | 271 | void *opaque |
| 274 | 272 | ){ |
| 275 | 273 | INTER_BLOCK(ob); |
| 276 | | - BLOB_APPEND_LITERAL(ob, "<table>\n"); |
| 274 | + blob_append_literal(ob, "<table>\n"); |
| 277 | 275 | if( head_row && blob_size(head_row)>0 ){ |
| 278 | | - BLOB_APPEND_LITERAL(ob, "<thead>\n"); |
| 279 | | - BLOB_APPEND_BLOB(ob, head_row); |
| 280 | | - BLOB_APPEND_LITERAL(ob, "</thead>\n<tbody>\n"); |
| 276 | + blob_append_literal(ob, "<thead>\n"); |
| 277 | + blob_appendb(ob, head_row); |
| 278 | + blob_append_literal(ob, "</thead>\n<tbody>\n"); |
| 281 | 279 | } |
| 282 | 280 | if( rows ){ |
| 283 | | - BLOB_APPEND_BLOB(ob, rows); |
| 281 | + blob_appendb(ob, rows); |
| 284 | 282 | } |
| 285 | 283 | if( head_row && blob_size(head_row)>0 ){ |
| 286 | | - BLOB_APPEND_LITERAL(ob, "</tbody>\n"); |
| 284 | + blob_append_literal(ob, "</tbody>\n"); |
| 287 | 285 | } |
| 288 | | - BLOB_APPEND_LITERAL(ob, "</table>\n"); |
| 286 | + blob_append_literal(ob, "</table>\n"); |
| 289 | 287 | } |
| 290 | 288 | |
| 291 | 289 | static void html_table_cell( |
| 292 | 290 | struct Blob *ob, |
| 293 | 291 | struct Blob *text, |
| 294 | 292 | int flags, |
| 295 | 293 | void *opaque |
| 296 | 294 | ){ |
| 297 | 295 | if( flags & MKD_CELL_HEAD ){ |
| 298 | | - BLOB_APPEND_LITERAL(ob, " <th"); |
| 296 | + blob_append_literal(ob, " <th"); |
| 299 | 297 | }else{ |
| 300 | | - BLOB_APPEND_LITERAL(ob, " <td"); |
| 298 | + blob_append_literal(ob, " <td"); |
| 301 | 299 | } |
| 302 | 300 | switch( flags & MKD_CELL_ALIGN_MASK ){ |
| 303 | 301 | case MKD_CELL_ALIGN_LEFT: { |
| 304 | | - BLOB_APPEND_LITERAL(ob, " align=\"left\""); |
| 302 | + blob_append_literal(ob, " align=\"left\""); |
| 305 | 303 | break; |
| 306 | 304 | } |
| 307 | 305 | case MKD_CELL_ALIGN_RIGHT: { |
| 308 | | - BLOB_APPEND_LITERAL(ob, " align=\"right\""); |
| 306 | + blob_append_literal(ob, " align=\"right\""); |
| 309 | 307 | break; |
| 310 | 308 | } |
| 311 | 309 | case MKD_CELL_ALIGN_CENTER: { |
| 312 | | - BLOB_APPEND_LITERAL(ob, " align=\"center\""); |
| 310 | + blob_append_literal(ob, " align=\"center\""); |
| 313 | 311 | break; |
| 314 | 312 | } |
| 315 | 313 | } |
| 316 | | - BLOB_APPEND_LITERAL(ob, ">"); |
| 317 | | - BLOB_APPEND_BLOB(ob, text); |
| 314 | + blob_append_literal(ob, ">"); |
| 315 | + blob_appendb(ob, text); |
| 318 | 316 | if( flags & MKD_CELL_HEAD ){ |
| 319 | | - BLOB_APPEND_LITERAL(ob, "</th>\n"); |
| 317 | + blob_append_literal(ob, "</th>\n"); |
| 320 | 318 | }else{ |
| 321 | | - BLOB_APPEND_LITERAL(ob, "</td>\n"); |
| 319 | + blob_append_literal(ob, "</td>\n"); |
| 322 | 320 | } |
| 323 | 321 | } |
| 324 | 322 | |
| 325 | 323 | static void html_table_row( |
| 326 | 324 | struct Blob *ob, |
| 327 | 325 | struct Blob *cells, |
| 328 | 326 | int flags, |
| 329 | 327 | void *opaque |
| 330 | 328 | ){ |
| 331 | | - BLOB_APPEND_LITERAL(ob, " <tr>\n"); |
| 332 | | - BLOB_APPEND_BLOB(ob, cells); |
| 333 | | - BLOB_APPEND_LITERAL(ob, " </tr>\n"); |
| 329 | + blob_append_literal(ob, " <tr>\n"); |
| 330 | + blob_appendb(ob, cells); |
| 331 | + blob_append_literal(ob, " </tr>\n"); |
| 334 | 332 | } |
| 335 | 333 | |
| 336 | | -/* Render a token of user provided classes. |
| 334 | +/* |
| 335 | +** Render a token of user provided classes. |
| 337 | 336 | ** If bHTML is true then render HTML for (presumably) visible text, |
| 338 | | -** otherwise just a space-separated list of the derived classes |
| 337 | +** otherwise just a space-separated list of the derived classes. |
| 339 | 338 | */ |
| 340 | 339 | static void append_footnote_upc( |
| 341 | 340 | struct Blob *ob, |
| 342 | 341 | const struct Blob *upc, /* token of user-provided classes */ |
| 343 | 342 | int bHTML |
| 344 | 343 | ){ |
| 345 | 344 | const char *z = blob_buffer(upc); |
| 346 | 345 | int i, n = blob_size(upc); |
| 346 | + |
| 347 | 347 | if( n<3 ) return; |
| 348 | 348 | assert( z[0]=='.' && z[n-1] == ':' ); |
| 349 | | - |
| 350 | 349 | if( bHTML ){ |
| 351 | 350 | blob_append_literal(ob, "<span class='fn-upc'>" |
| 352 | 351 | "<span class='fn-upcDot'>.</span>"); |
| 353 | 352 | } |
| 354 | 353 | n = 0; |
| | @@ -394,29 +393,28 @@ |
| 394 | 393 | char pos[32]; |
| 395 | 394 | memset(pos,0,32); |
| 396 | 395 | assert( locus > 0 ); |
| 397 | 396 | /* expect BUGs if the following yields compiler warnings */ |
| 398 | 397 | if( iMark > 0 ){ /* a regular reference to a footnote */ |
| 399 | | - |
| 400 | | - sprintf(pos, "%s-%i-%s", ctx->unique.c, iMark, l.c); |
| 398 | + sprintf(pos, "%s-%d-%s", ctx->unique.c, iMark, l.c); |
| 401 | 399 | if(span && blob_size(span)) { |
| 402 | 400 | blob_append_literal(ob,"<span class='"); |
| 403 | 401 | append_footnote_upc(ob, upc, 0); |
| 404 | 402 | blob_append_literal(ob,"notescope' id='noteref"); |
| 405 | 403 | blob_appendf(ob,"%s'>",pos); |
| 406 | 404 | blob_appendb(ob, span); |
| 407 | 405 | blob_trim(ob); |
| 408 | 406 | blob_append_literal(ob,"<sup class='noteref'><a href='"); |
| 409 | 407 | BLOB_APPEND_URI(ob, ctx); |
| 410 | | - blob_appendf(ob,"#footnote%s'>%i</a></sup></span>", pos, iMark); |
| 408 | + blob_appendf(ob,"#footnote%s'>%d</a></sup></span>", pos, iMark); |
| 411 | 409 | }else{ |
| 412 | 410 | blob_trim(ob); |
| 413 | 411 | blob_append_literal(ob,"<sup class='"); |
| 414 | 412 | append_footnote_upc(ob, upc, 0); |
| 415 | 413 | blob_append_literal(ob,"noteref'><a href='"); |
| 416 | 414 | BLOB_APPEND_URI(ob, ctx); |
| 417 | | - blob_appendf(ob,"#footnote%s' id='noteref%s'>%i</a></sup>", |
| 415 | + blob_appendf(ob,"#footnote%s' id='noteref%s'>%d</a></sup>", |
| 418 | 416 | pos, pos, iMark); |
| 419 | 417 | } |
| 420 | 418 | }else{ /* misreference */ |
| 421 | 419 | assert( iMark == -1 ); |
| 422 | 420 | |
| | @@ -470,21 +468,19 @@ |
| 470 | 468 | blob_appendf(ob,"#misref%s-%c'>%c</a>", unique,c, c); |
| 471 | 469 | } |
| 472 | 470 | if( i < nUsed ) blob_append_literal(ob," …"); |
| 473 | 471 | } |
| 474 | 472 | blob_append_literal(ob,"</sup>\n<span>Misreference</span>"); |
| 475 | | - |
| 476 | 473 | }else if( iMark > 0 ){ /* regular, joined and overnested footnotes */ |
| 477 | 474 | char pos[24]; |
| 478 | 475 | int bJoin = 0; |
| 479 | 476 | #define _joined_footnote_indicator "<ul class='fn-joined'>" |
| 480 | 477 | #define _jfi_sz (sizeof(_joined_footnote_indicator)-1) |
| 481 | 478 | assert( text ); |
| 482 | 479 | assert( blob_size(text) ); |
| 483 | 480 | memset(pos,0,24); |
| 484 | | - sprintf(pos, "%s-%i", unique, iMark); |
| 485 | | - |
| 481 | + sprintf(pos, "%s-%d", unique, iMark); |
| 486 | 482 | blob_appendf(ob, "<li id='footnote%s' class='", pos); |
| 487 | 483 | if( nUsed ){ |
| 488 | 484 | if( blob_size(text)>=_jfi_sz && |
| 489 | 485 | !memcmp(blob_buffer(text),_joined_footnote_indicator,_jfi_sz)){ |
| 490 | 486 | bJoin = 1; |
| | @@ -492,11 +488,10 @@ |
| 492 | 488 | } |
| 493 | 489 | append_footnote_upc(ob, upc, 0); |
| 494 | 490 | }else{ |
| 495 | 491 | blob_append_literal(ob, "fn-toodeep "); |
| 496 | 492 | } |
| 497 | | - |
| 498 | 493 | if( nUsed <= 1 ){ |
| 499 | 494 | blob_append_literal(ob, "fn-monoref'><sup class='fn-backrefs'>"); |
| 500 | 495 | blob_appendf(ob,"<a id='footnote%s-a' href='", pos); |
| 501 | 496 | BLOB_APPEND_URI(ob, ctx); |
| 502 | 497 | blob_appendf(ob,"#noteref%s-a'>^</a>", pos); |
| | @@ -554,10 +549,11 @@ |
| 554 | 549 | html_escape(ob, blob_buffer(text), blob_size(text)); |
| 555 | 550 | blob_append_literal(ob,"</code></pre>"); |
| 556 | 551 | } |
| 557 | 552 | blob_append_literal(ob, "\n</li>\n"); |
| 558 | 553 | } |
| 554 | + |
| 559 | 555 | static void html_footnotes( |
| 560 | 556 | struct Blob *ob, const struct Blob *items, void *opaque |
| 561 | 557 | ){ |
| 562 | 558 | if( items && blob_size(items) ){ |
| 563 | 559 | blob_append_literal(ob, |
| | @@ -579,21 +575,21 @@ |
| 579 | 575 | struct Blob *link, |
| 580 | 576 | enum mkd_autolink type, |
| 581 | 577 | void *opaque |
| 582 | 578 | ){ |
| 583 | 579 | if( !link || blob_size(link)<=0 ) return 0; |
| 584 | | - BLOB_APPEND_LITERAL(ob, "<a href=\""); |
| 585 | | - if( type==MKDA_IMPLICIT_EMAIL ) BLOB_APPEND_LITERAL(ob, "mailto:"); |
| 580 | + blob_append_literal(ob, "<a href=\""); |
| 581 | + if( type==MKDA_IMPLICIT_EMAIL ) blob_append_literal(ob, "mailto:"); |
| 586 | 582 | html_quote(ob, blob_buffer(link), blob_size(link)); |
| 587 | | - BLOB_APPEND_LITERAL(ob, "\">"); |
| 583 | + blob_append_literal(ob, "\">"); |
| 588 | 584 | if( type==MKDA_EXPLICIT_EMAIL && blob_size(link)>7 ){ |
| 589 | 585 | /* remove "mailto:" from displayed text */ |
| 590 | 586 | html_escape(ob, blob_buffer(link)+7, blob_size(link)-7); |
| 591 | 587 | }else{ |
| 592 | 588 | html_escape(ob, blob_buffer(link), blob_size(link)); |
| 593 | 589 | } |
| 594 | | - BLOB_APPEND_LITERAL(ob, "</a>"); |
| 590 | + blob_append_literal(ob, "</a>"); |
| 595 | 591 | return 1; |
| 596 | 592 | } |
| 597 | 593 | |
| 598 | 594 | /* |
| 599 | 595 | ** The nSrc bytes at zSrc[] are Pikchr input text (allegedly). Process that |
| | @@ -682,13 +678,13 @@ |
| 682 | 678 | ){ |
| 683 | 679 | if( text==0 ){ |
| 684 | 680 | /* no-op */ |
| 685 | 681 | }else if( nSep<=2 ){ |
| 686 | 682 | /* One or two graves: an in-line code span */ |
| 687 | | - BLOB_APPEND_LITERAL(ob, "<code>"); |
| 683 | + blob_append_literal(ob, "<code>"); |
| 688 | 684 | html_escape(ob, blob_buffer(text), blob_size(text)); |
| 689 | | - BLOB_APPEND_LITERAL(ob, "</code>"); |
| 685 | + blob_append_literal(ob, "</code>"); |
| 690 | 686 | }else{ |
| 691 | 687 | /* Three or more graves: a fenced code block */ |
| 692 | 688 | int n = blob_size(text); |
| 693 | 689 | const char *z = blob_buffer(text); |
| 694 | 690 | int i; |
| | @@ -720,25 +716,25 @@ |
| 720 | 716 | struct Blob *ob, |
| 721 | 717 | struct Blob *text, |
| 722 | 718 | char c, |
| 723 | 719 | void *opaque |
| 724 | 720 | ){ |
| 725 | | - BLOB_APPEND_LITERAL(ob, "<strong>"); |
| 726 | | - BLOB_APPEND_BLOB(ob, text); |
| 727 | | - BLOB_APPEND_LITERAL(ob, "</strong>"); |
| 721 | + blob_append_literal(ob, "<strong>"); |
| 722 | + blob_appendb(ob, text); |
| 723 | + blob_append_literal(ob, "</strong>"); |
| 728 | 724 | return 1; |
| 729 | 725 | } |
| 730 | 726 | |
| 731 | 727 | static int html_emphasis( |
| 732 | 728 | struct Blob *ob, |
| 733 | 729 | struct Blob *text, |
| 734 | 730 | char c, |
| 735 | 731 | void *opaque |
| 736 | 732 | ){ |
| 737 | | - BLOB_APPEND_LITERAL(ob, "<em>"); |
| 738 | | - BLOB_APPEND_BLOB(ob, text); |
| 739 | | - BLOB_APPEND_LITERAL(ob, "</em>"); |
| 733 | + blob_append_literal(ob, "<em>"); |
| 734 | + blob_appendb(ob, text); |
| 735 | + blob_append_literal(ob, "</em>"); |
| 740 | 736 | return 1; |
| 741 | 737 | } |
| 742 | 738 | |
| 743 | 739 | static int html_image( |
| 744 | 740 | struct Blob *ob, |
| | @@ -745,24 +741,24 @@ |
| 745 | 741 | struct Blob *link, |
| 746 | 742 | struct Blob *title, |
| 747 | 743 | struct Blob *alt, |
| 748 | 744 | void *opaque |
| 749 | 745 | ){ |
| 750 | | - BLOB_APPEND_LITERAL(ob, "<img src=\""); |
| 746 | + blob_append_literal(ob, "<img src=\""); |
| 751 | 747 | html_quote(ob, blob_buffer(link), blob_size(link)); |
| 752 | | - BLOB_APPEND_LITERAL(ob, "\" alt=\""); |
| 748 | + blob_append_literal(ob, "\" alt=\""); |
| 753 | 749 | html_quote(ob, blob_buffer(alt), blob_size(alt)); |
| 754 | 750 | if( title && blob_size(title)>0 ){ |
| 755 | | - BLOB_APPEND_LITERAL(ob, "\" title=\""); |
| 751 | + blob_append_literal(ob, "\" title=\""); |
| 756 | 752 | html_quote(ob, blob_buffer(title), blob_size(title)); |
| 757 | 753 | } |
| 758 | | - BLOB_APPEND_LITERAL(ob, "\" />"); |
| 754 | + blob_append_literal(ob, "\" />"); |
| 759 | 755 | return 1; |
| 760 | 756 | } |
| 761 | 757 | |
| 762 | 758 | static int html_linebreak(struct Blob *ob, void *opaque){ |
| 763 | | - BLOB_APPEND_LITERAL(ob, "<br />\n"); |
| 759 | + blob_append_literal(ob, "<br />\n"); |
| 764 | 760 | return 1; |
| 765 | 761 | } |
| 766 | 762 | |
| 767 | 763 | static int html_link( |
| 768 | 764 | struct Blob *ob, |
| | @@ -783,13 +779,13 @@ |
| 783 | 779 | WIKI_MARKDOWNLINKS |
| 784 | 780 | ; |
| 785 | 781 | wiki_resolve_hyperlink(ob, flags, zLink, zClose, sizeof(zClose), 0, zTitle); |
| 786 | 782 | } |
| 787 | 783 | if( blob_size(content)==0 ){ |
| 788 | | - if( link ) BLOB_APPEND_BLOB(ob, link); |
| 784 | + if( link ) blob_appendb(ob, link); |
| 789 | 785 | }else{ |
| 790 | | - BLOB_APPEND_BLOB(ob, content); |
| 786 | + blob_appendb(ob, content); |
| 791 | 787 | } |
| 792 | 788 | blob_append(ob, zClose, -1); |
| 793 | 789 | return 1; |
| 794 | 790 | } |
| 795 | 791 | |
| | @@ -797,13 +793,13 @@ |
| 797 | 793 | struct Blob *ob, |
| 798 | 794 | struct Blob *text, |
| 799 | 795 | char c, |
| 800 | 796 | void *opaque |
| 801 | 797 | ){ |
| 802 | | - BLOB_APPEND_LITERAL(ob, "<strong><em>"); |
| 803 | | - BLOB_APPEND_BLOB(ob, text); |
| 804 | | - BLOB_APPEND_LITERAL(ob, "</em></strong>"); |
| 798 | + blob_append_literal(ob, "<strong><em>"); |
| 799 | + blob_appendb(ob, text); |
| 800 | + blob_append_literal(ob, "</em></strong>"); |
| 805 | 801 | return 1; |
| 806 | 802 | } |
| 807 | 803 | |
| 808 | 804 | |
| 809 | 805 | static void html_normal_text(struct Blob *ob, struct Blob *text, void *opaque){ |
| 810 | 806 | |