Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When markdown begins with a <h1> HTML element, consider the content of that element to be the title of the document. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
cc7f4df41743ffc010e8293106935830 |
User & Date: | drh 2015-12-03 15:07:27.859 |
Context
2015-12-03
| ||
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) | |
2015-12-02
| ||
20:18 | Fix harmless compiler warning. ... (check-in: a3691d76 user: mistachkin tags: trunk) | |
Changes
Changes to src/markdown_html.c.
︙ | ︙ | |||
97 98 99 100 101 102 103 | static void html_epilog(struct Blob *ob, void *opaque){ 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); | | > > > > > > > > > > > > < < | | 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 122 123 124 125 | static void html_epilog(struct Blob *ob, void *opaque){ 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 ){ Blob *title = (Blob*)opaque; int nTag = htmlTagLength(data); blob_append(title, data+nTag, size - nTag - 5); } 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){ INTER_BLOCK(ob); BLOB_APPEND_LITERAL(ob, "<pre><code>"); html_escape(ob, blob_buffer(text), blob_size(text)); |
︙ | ︙ | |||
252 253 254 255 256 257 258 259 260 261 262 263 264 265 | } /* HTML span tags */ static int html_raw_span(struct Blob *ob, struct Blob *text, void *opaque){ BLOB_APPEND_BLOB(ob, text); return 1; } static int html_autolink( struct Blob *ob, struct Blob *link, | > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | } /* HTML span tags */ static int html_raw_span(struct Blob *ob, struct Blob *text, void *opaque){ /* If the document begins with a <h1> markup, take that as the header. */ BLOB_APPEND_BLOB(ob, text); return 1; } static int html_autolink( struct Blob *ob, struct Blob *link, |
︙ | ︙ |
Changes to src/wikiformat.c.
︙ | ︙ | |||
465 466 467 468 469 470 471 | /* ** z points to a "<" character. Check to see if this is the start of ** a valid markup. If it is, return the total number of characters in ** the markup including the initial "<" and the terminating ">". If ** it is not well-formed markup, return 0. */ | | | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | /* ** z points to a "<" character. Check to see if this is the start of ** a valid markup. If it is, return the total number of characters in ** the markup including the initial "<" and the terminating ">". If ** it is not well-formed markup, return 0. */ int htmlTagLength(const char *z){ int n = 1; int inparen = 0; int c; if( z[n]=='/' ){ n++; } if( !fossil_isalpha(z[n]) ) return 0; while( fossil_isalnum(z[n]) || z[n]=='-' ){ n++; } c = z[n]; |
︙ | ︙ | |||
660 661 662 663 664 665 666 | ** ** z points to the start of a token. Return the number of ** characters in that token. Write the token type into *pTokenType. */ static int nextWikiToken(const char *z, Renderer *p, int *pTokenType){ int n; if( z[0]=='<' ){ | | | 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | ** ** z points to the start of a token. Return the number of ** characters in that token. Write the token type into *pTokenType. */ static int nextWikiToken(const char *z, Renderer *p, int *pTokenType){ int n; if( z[0]=='<' ){ n = htmlTagLength(z); if( n>0 ){ *pTokenType = TOKEN_MARKUP; return n; }else{ *pTokenType = TOKEN_CHARACTER; return 1; } |
︙ | ︙ | |||
1970 1971 1972 1973 1974 1975 1976 | ** z points to the start of a token. Return the number of ** characters in that token. */ static int nextHtmlToken(const char *z){ int n; char c; if( (c=z[0])=='<' ){ | | | 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 | ** z points to the start of a token. Return the number of ** characters in that token. */ static int nextHtmlToken(const char *z){ int n; char c; if( (c=z[0])=='<' ){ n = htmlTagLength(z); if( n<=0 ) n = 1; }else if( fossil_isspace(c) ){ for(n=1; z[n] && fossil_isspace(z[n]); n++){} }else if( c=='&' ){ n = z[1]=='#' ? 2 : 1; while( fossil_isalnum(z[n]) ) n++; if( z[n]==';' ) n++; |
︙ | ︙ |