Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Do not duplicate markdown titles in the title of the page and in the body of the document. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d407c3842116e163fce36055c3998e08 |
User & Date: | drh 2015-12-03 15:19:39.583 |
Context
2015-12-03
| ||
15:41 | Improved cross-linking of clusters. ... (check-in: 24606598 user: drh tags: trunk) | |
15:19 | Do not duplicate markdown titles in the title of the page and in the body of the document. ... (check-in: d407c384 user: drh tags: trunk) | |
15:07 | When markdown begins with a <h1> HTML element, consider the content of that element to be the title of the document. ... (check-in: cc7f4df4 user: drh tags: trunk) | |
Changes
Changes to src/markdown_html.c.
︙ | ︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | INTER_BLOCK(ob); BLOB_APPEND_LITERAL(ob, "</div>\n"); } static void html_raw_block(struct Blob *ob, struct Blob *text, void *opaque){ char *data = blob_buffer(text); size_t size = blob_size(text); while( size>0 && fossil_isspace(data[0]) ){ data++; size--; } while( size>0 && fossil_isspace(data[size-1]) ){ size--; } /* If the first raw block is an <h1> element, then use it as the title. */ if( blob_size(ob)<=PROLOG_SIZE && size>9 && sqlite3_strnicmp("<h1",data,3)==0 && sqlite3_strnicmp("</h1>", &data[size-5],5)==0 ){ | > > < > | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | INTER_BLOCK(ob); BLOB_APPEND_LITERAL(ob, "</div>\n"); } static void html_raw_block(struct Blob *ob, struct Blob *text, void *opaque){ char *data = blob_buffer(text); size_t size = blob_size(text); Blob *title = (Blob*)opaque; while( size>0 && fossil_isspace(data[0]) ){ data++; size--; } while( size>0 && fossil_isspace(data[size-1]) ){ size--; } /* If the first raw block is an <h1> element, then use it as the title. */ if( blob_size(ob)<=PROLOG_SIZE && size>9 && title!=0 && sqlite3_strnicmp("<h1",data,3)==0 && sqlite3_strnicmp("</h1>", &data[size-5],5)==0 ){ int nTag = htmlTagLength(data); blob_append(title, data+nTag, size - nTag - 5); return; } INTER_BLOCK(ob); blob_append(ob, data, size); BLOB_APPEND_LITERAL(ob, "\n"); } static void html_blockcode(struct Blob *ob, struct Blob *text, void *opaque){ |
︙ | ︙ | |||
138 139 140 141 142 143 144 | struct Blob *text, int level, void *opaque ){ struct Blob *title = opaque; /* The first header at the beginning of a text is considered as * a title and not output. */ | | > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | struct Blob *text, int level, void *opaque ){ struct Blob *title = opaque; /* The first header at the beginning of a text is considered as * a title and not output. */ if( blob_size(ob)<=PROLOG_SIZE && title!=0 && blob_size(title)==0 ){ BLOB_APPEND_BLOB(title, text); return; } INTER_BLOCK(ob); blob_appendf(ob, "<h%d>", level); BLOB_APPEND_BLOB(ob, text); blob_appendf(ob, "</h%d>", level); } |
︙ | ︙ | |||
379 380 381 382 383 384 385 | } static void html_normal_text(struct Blob *ob, struct Blob *text, void *opaque){ html_escape(ob, blob_buffer(text), blob_size(text)); } | | > > > > > | | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | } static void html_normal_text(struct Blob *ob, struct Blob *text, void *opaque){ html_escape(ob, blob_buffer(text), blob_size(text)); } /* ** Convert markdown into HTML. ** ** The document title is placed in output_title if not NULL. Or if ** output_title is NULL, the document title appears in the body. */ void markdown_to_html( struct Blob *input_markdown, /* Markdown content to be rendered */ struct Blob *output_title, /* Put title here. May be NULL */ struct Blob *output_body /* Put document body here. */ ){ struct mkd_renderer html_renderer = { /* prolog and epilog */ html_prolog, html_epilog, /* block level elements */ |
︙ | ︙ | |||
424 425 426 427 428 429 430 | /* misc. parameters */ 64, /* maximum stack */ "*_", /* emphasis characters */ 0 /* opaque data */ }; html_renderer.opaque = output_title; | | | 432 433 434 435 436 437 438 439 440 441 442 | /* misc. parameters */ 64, /* maximum stack */ "*_", /* emphasis characters */ 0 /* opaque data */ }; html_renderer.opaque = output_title; if( output_title ) blob_reset(output_title); blob_reset(output_body); markdown(output_body, input_markdown, &html_renderer); } |
Changes to src/wiki.c.
︙ | ︙ | |||
145 146 147 148 149 150 151 | ** text/x-markdown Markdown ** anything else... Plain text */ void wiki_render_by_mimetype(Blob *pWiki, const char *zMimetype){ if( zMimetype==0 || fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0 ){ wiki_convert(pWiki, 0, 0); }else if( fossil_strcmp(zMimetype, "text/x-markdown")==0 ){ | < | < < < < < < | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | ** text/x-markdown Markdown ** anything else... Plain text */ void wiki_render_by_mimetype(Blob *pWiki, const char *zMimetype){ if( zMimetype==0 || fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0 ){ wiki_convert(pWiki, 0, 0); }else if( fossil_strcmp(zMimetype, "text/x-markdown")==0 ){ Blob tail = BLOB_INITIALIZER; markdown_to_html(pWiki, 0, &tail); @ %s(blob_str(&tail)) blob_reset(&tail); }else{ @ <pre> @ %h(blob_str(pWiki)) @ </pre> } } |
︙ | ︙ |