Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Avoid unnecessary quoting of ASCII characters 34 and 39 in the markdown formatter. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7950dc2297431d373d157a9bcadba1dd |
User & Date: | drh 2018-09-21 13:57:13.539 |
Context
2018-09-22
| ||
00:22 | Fix the indented paragraph on the homepage. ... (check-in: 0d7ac90d user: drh tags: trunk) | |
2018-09-21
| ||
13:57 | Avoid unnecessary quoting of ASCII characters 34 and 39 in the markdown formatter. ... (check-in: 7950dc22 user: drh tags: trunk) | |
12:34 | Back out the block-indentation CSS change from check-in [2190f86c324d0f57fa4f8]. ... (check-in: eae0a982 user: drh tags: trunk) | |
Changes
Changes to src/markdown_html.c.
︙ | ︙ | |||
46 47 48 49 50 51 52 | */ /* BLOB_APPEND_BLOB -- append blob contents to another */ #define BLOB_APPEND_BLOB(dest, src) \ blob_append((dest), blob_buffer(src), blob_size(src)) | | | > > > | > | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | */ /* BLOB_APPEND_BLOB -- append blob contents to another */ #define BLOB_APPEND_BLOB(dest, src) \ blob_append((dest), blob_buffer(src), blob_size(src)) /* HTML escapes ** ** html_escape() converts < to <, > to >, and & to &. ** html_quote() goes further and converts " into " and ' in '. */ static void html_quote(struct Blob *ob, const char *data, size_t size){ size_t beg = 0, i = 0; while( i<size ){ beg = i; while( i<size && data[i]!='<' && data[i]!='>' && data[i]!='"' && data[i]!='&' && data[i]!='\'' ){ i++; } blob_append(ob, data+beg, i-beg); while( i<size ){ if( data[i]=='<' ){ BLOB_APPEND_LITERAL(ob, "<"); |
︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 | BLOB_APPEND_LITERAL(ob, "'"); }else{ break; } i++; } } } /* HTML block tags */ /* Size of the prolog: "<div class='markdown'>\n" */ #define PROLOG_SIZE 23 | > > > > > > > > > > > > > > > > > > > > > > > > > > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | BLOB_APPEND_LITERAL(ob, "'"); }else{ break; } i++; } } } static void html_escape(struct Blob *ob, const char *data, size_t size){ size_t beg = 0, i = 0; while( i<size ){ beg = i; while( i<size && data[i]!='<' && data[i]!='>' && data[i]!='&' ){ i++; } blob_append(ob, data+beg, i-beg); while( i<size ){ if( data[i]=='<' ){ BLOB_APPEND_LITERAL(ob, "<"); }else if( data[i]=='>' ){ BLOB_APPEND_LITERAL(ob, ">"); }else if( data[i]=='&' ){ BLOB_APPEND_LITERAL(ob, "&"); }else{ break; } i++; } } } /* HTML block tags */ /* Size of the prolog: "<div class='markdown'>\n" */ #define PROLOG_SIZE 23 |
︙ | ︙ | |||
281 282 283 284 285 286 287 | struct Blob *link, enum mkd_autolink type, void *opaque ){ if( !link || blob_size(link)<=0 ) return 0; BLOB_APPEND_LITERAL(ob, "<a href=\""); if( type==MKDA_IMPLICIT_EMAIL ) BLOB_APPEND_LITERAL(ob, "mailto:"); | | | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | struct Blob *link, enum mkd_autolink type, void *opaque ){ if( !link || blob_size(link)<=0 ) return 0; BLOB_APPEND_LITERAL(ob, "<a href=\""); if( type==MKDA_IMPLICIT_EMAIL ) BLOB_APPEND_LITERAL(ob, "mailto:"); html_quote(ob, blob_buffer(link), blob_size(link)); BLOB_APPEND_LITERAL(ob, "\">"); if( type==MKDA_EXPLICIT_EMAIL && blob_size(link)>7 ){ /* remove "mailto:" from displayed text */ html_escape(ob, blob_buffer(link)+7, blob_size(link)-7); }else{ html_escape(ob, blob_buffer(link), blob_size(link)); } |
︙ | ︙ | |||
334 335 336 337 338 339 340 | struct Blob *ob, struct Blob *link, struct Blob *title, struct Blob *alt, void *opaque ){ BLOB_APPEND_LITERAL(ob, "<img src=\""); | | | | | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | struct Blob *ob, struct Blob *link, struct Blob *title, struct Blob *alt, void *opaque ){ BLOB_APPEND_LITERAL(ob, "<img src=\""); html_quote(ob, blob_buffer(link), blob_size(link)); BLOB_APPEND_LITERAL(ob, "\" alt=\""); html_quote(ob, blob_buffer(alt), blob_size(alt)); if( title && blob_size(title)>0 ){ BLOB_APPEND_LITERAL(ob, "\" title=\""); html_quote(ob, blob_buffer(title), blob_size(title)); } BLOB_APPEND_LITERAL(ob, "\" />"); return 1; } static int html_line_break(struct Blob *ob, void *opaque){ BLOB_APPEND_LITERAL(ob, "<br />\n"); |
︙ | ︙ | |||
364 365 366 367 368 369 370 | char *zLink = blob_buffer(link); BLOB_APPEND_LITERAL(ob, "<a href=\""); if( zLink && zLink[0]=='/' && g.zTop ){ /* For any hyperlink that begins with "/", make it refer to the root ** of the Fossil repository */ blob_append(ob, g.zTop, -1); } | | | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | char *zLink = blob_buffer(link); BLOB_APPEND_LITERAL(ob, "<a href=\""); if( zLink && zLink[0]=='/' && g.zTop ){ /* For any hyperlink that begins with "/", make it refer to the root ** of the Fossil repository */ blob_append(ob, g.zTop, -1); } html_quote(ob, blob_buffer(link), blob_size(link)); if( title && blob_size(title)>0 ){ BLOB_APPEND_LITERAL(ob, "\" title=\""); html_quote(ob, blob_buffer(title), blob_size(title)); } BLOB_APPEND_LITERAL(ob, "\">"); BLOB_APPEND_BLOB(ob, content); BLOB_APPEND_LITERAL(ob, "</a>"); return 1; } |
︙ | ︙ |