Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | mods to creole parser and add some default style for creole tables. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | creole |
| Files: | files | file ages | folders |
| SHA1: |
26af399a5c96dc30fa494a3b69c2ad64 |
| User & Date: | robert 2009-05-09 06:19:39.000 |
Context
|
2009-09-22
| ||
| 07:49 | merge trunk into creole branch ... (check-in: 7a2c37063a user: bob tags: creole) | |
|
2009-05-09
| ||
| 06:19 | mods to creole parser and add some default style for creole tables. ... (check-in: 26af399a5c user: robert tags: creole) | |
|
2009-05-08
| ||
| 10:04 | Whoops - forgot to add the parser! ... (check-in: b877d2cfcd user: robert tags: creole) | |
Changes
Changes to src/creoleparser.c.
| ︙ | ︙ | |||
34 35 36 37 38 39 40 |
#endif
//{{{ LOCAL INTERFACE
#if LOCAL_INTERFACE
#define POOL_CHUNK_SIZE 100
| > | | | | | | | | | | | | | | | | | | > > | | > | 34 35 36 37 38 39 40 41 42 43 44 45 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 75 76 77 78 79 80 81 82 |
#endif
//{{{ LOCAL INTERFACE
#if LOCAL_INTERFACE
#define POOL_CHUNK_SIZE 100
//{{{ KIND
#define KIND_ROOT 0x0000001
#define KIND_HORIZONTAL_RULE 0x0000002
#define KIND_HEADING 0x0000004
#define KIND_ORDERED_LIST 0x0000008
#define KIND_UNORDERED_LIST 0x0000010
#define KIND_PARAGRAPH 0x0000020
#define KIND_TABLE 0x0000040
#define KIND_NO_WIKI_BLOCK 0x0000080
#define KIND_PARA_BREAK 0x0000100
#define KIND_END_WIKI_MARKER 0x0000200
#define KIND_BOLD 0x0000400
#define KIND_ITALIC 0x0000800
#define KIND_SUPERSCRIPT 0x0001000
#define KIND_SUBSCRIPT 0x0002000
#define KIND_MONOSPACED 0x0004000
#define KIND_BREAK 0x0008000
#define KIND_TABLE_ROW 0x0010000
//}}}
//{{{ FLAG
// keep first four bits free
#define FLAG_CENTER 0x0000100
//}}}
struct Node {//{{{
char *start;
char *end;
int kind;
int level;
int flags;
Node *parent;
Node *next;
Node *children;
};
//}}}
|
| ︙ | ︙ | |||
109 110 111 112 113 114 115 | Blob *iblob; }; | < < | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | Blob *iblob; }; //}}} #endif const int KIND_LIST = (KIND_UNORDERED_LIST | KIND_ORDERED_LIST); const int KIND_LIST_OR_PARAGRAPH = (KIND_PARAGRAPH | KIND_UNORDERED_LIST | KIND_ORDERED_LIST); //}}} |
| ︙ | ︙ | |||
358 359 360 361 362 363 364 |
return 0;
char *s = p->icursor + 3;
int count = p->iend - p->icursor - 6;
while (count--){
if (s[0]=='}' && s[1]=='}' && s[2]=='}' && s[3]!='}'){
| | > | | < > > | > > > > > > > > > > > > > > > > > > > | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
return 0;
char *s = p->icursor + 3;
int count = p->iend - p->icursor - 6;
while (count--){
if (s[0]=='}' && s[1]=='}' && s[2]=='}' && s[3]!='}'){
blob_appendf(p->iblob, "<tt style='background:oldlace'>%s</tt>", htmlize(p->icursor + 3, s - p->icursor-3));
p->icursor = s + 3;
return 1;
}
s++;
}
return 0;
}
//}}}
static int cr_iImage(Parser *p){//{{{
if (p->inLink) return 0;
if ((p->iend - p->icursor)<3) return 0;
if (p->icursor[1]!='{') return 0;
char *s = p->icursor + 2;
char *bar = NULL;
int count = p->iend - p->icursor - 4;
while (count--){
if (s[0]=='}' && s[1]=='}'){
if (!bar) bar = p->icursor + 2;
blob_appendf(p->iblob, "<span style='color:green;border:1px solid green;'>%s</span>", htmlize(bar, s - bar ));
p->icursor = s + 2;
return 1;
}
if (!bar && s[0]=='|') bar=s+1;
s++;
}
return 0;
}
//}}}
static int cr_iMacro(Parser *p){//{{{
if (p->inLink) return 0;
if ((p->iend - p->icursor)<3) return 0;
if (p->icursor[1]!='<') return 0;
char *s = p->icursor + 2;
int count = p->iend - p->icursor - 4;
while (count--){
if (s[0]=='>' && s[1]=='>'){
blob_appendf(p->iblob, "<span style='color:red;border:1px solid red;'>%s</span>", htmlize(p->icursor, s - p->icursor + 2));
p->icursor = s + 2;
return 1;
}
s++;
}
return 0;
}
//}}}
static void cr_renderLink(Parser *p, char *s, char *bar, char *e){//{{{
int tsize = bar-s;
int dsize = e - bar-1;
|
| ︙ | ︙ | |||
579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
p->istack = save_istack;
return eof;
}
//}}}
//}}}
static void cr_renderListItem(Parser *p, Node *n){//{{{
blob_append(p->iblob, "<li>", 4);
cr_parseInline(p, n->start, n->end);
| > > | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
p->istack = save_istack;
return eof;
}
//}}}
//}}}
//{{{ BLOCK PARSER
static void cr_renderListItem(Parser *p, Node *n){//{{{
blob_append(p->iblob, "<li>", 4);
cr_parseInline(p, n->start, n->end);
|
| ︙ | ︙ | |||
604 605 606 607 608 609 610 | } if (ord) blob_append(p->iblob, "</ol>", 5); else blob_append(p->iblob, "</ul>", 5); } blob_append(p->iblob, "</li>", 5); } | | | | 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
}
if (ord) blob_append(p->iblob, "</ol>", 5);
else blob_append(p->iblob, "</ul>", 5);
}
blob_append(p->iblob, "</li>", 5);
}
//}}}
static void cr_renderList(Parser *p){//{{{
Node *n = p->list;
while (n->parent !=n) n = n->parent;
int ord = (n->kind & KIND_ORDERED_LIST);
|
| ︙ | ︙ | |||
656 657 658 659 660 661 662 | blob_append(p->iblob, "</td>\n", -1); if (!s) break; } blob_append(p->iblob, "</tr>", 5); } //}}} | < < < | < | > > | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
blob_append(p->iblob, "</td>\n", -1);
if (!s) break;
}
blob_append(p->iblob, "</tr>", 5);
}
//}}}
static void cr_renderTable(Parser *p, Node *n){//{{{
Node *row = n->children;
blob_append(p->iblob, "<table class='creoletable'>", -1);
p->inTable = 1;
while (row){
cr_renderTableRow(p, row);
row = row->next;
}
blob_append(p->iblob, "</table>", -1);
p->inTable = 0;
}
//}}}
static void cr_render(Parser *p, Node *node){//{{{
if (node->kind & KIND_PARAGRAPH){
blob_append(p->iblob, "\n<p>", -1);
cr_parseInline(p, node->start, node->end );
blob_append(p->iblob, "</p>\n", -1 );
}
if (node->kind & KIND_HEADING){
blob_appendf(p->iblob,
"\n<h%d %s>",
node->level,
(node->flags & FLAG_CENTER) ? " style='text-align:center;'" : ""
);
cr_parseInline(p, node->start, node->end);
blob_appendf(p->iblob, "</h%d>\n", node->level );
return;
}
if (node->kind & KIND_HORIZONTAL_RULE){
blob_append(p->iblob, "<hr />", -1);
return;
}
|
| ︙ | ︙ | |||
720 721 722 723 724 725 726 | "\n<blockquote style='background:oldlace'><pre>%s</pre></blockquote>\n", htmlize( node->start, node->end - node->start) ); } } //}}} | < < | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
"\n<blockquote style='background:oldlace'><pre>%s</pre></blockquote>\n",
htmlize( node->start, node->end - node->start)
);
}
}
//}}}
static char *cr_findEndOfBlock(Parser *p, char *s, char c){//{{{
char *end;
while (s[0]){
end = s;
if (s[0] == c && s[0] == c && s[0] == c) {
s = cr_nextLine(p, s + 3);
if (p->lineWasBlank) {
p->cursor = s;
return end;
}
}
else {
s = cr_nextLine(p, s);
}
}
return 0;
}
//}}}
static int cr_addListItem(Parser *p, Node *n){//{{{
n->parent = n;
n->next = n->children = NULL;
if (!p->list) {
if (n->level != 1) return 0;
|
| ︙ | ︙ | |||
780 781 782 783 784 785 786 | n->parent = p->list; p->list->children = n; p->list = n; return 1; } //}}} | < | 801 802 803 804 805 806 807 808 809 810 811 812 813 814 |
n->parent = p->list;
p->list->children = n;
p->list = n;
return 1;
}
//}}}
static int isEndWikiMarker(Parser *p){//{{{
char *s = p->cursor;
if (memcmp(s, "<<fossil>>", 10)) return 0;
p->this->start = s;
p->this->kind = KIND_END_WIKI_MARKER;
|
| ︙ | ︙ | |||
830 831 832 833 834 835 836 837 838 839 |
return 1;
}
//}}}
static int isHeading(Parser *p){//{{{
char *s = cr_skipBlanks(p, p->cursor);
int level = cr_countChars(p, s, '=');
if (!level) return 0;
| > > > > > > > | > | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 |
return 1;
}
//}}}
static int isHeading(Parser *p){//{{{
char *s = cr_skipBlanks(p, p->cursor);
int flags = 0;
int level = cr_countChars(p, s, '=');
if (!level) return 0;
s += level;
if (s[0] == '<' && s[1] == '>') {
flags |= FLAG_CENTER;
s += 2;
}
s = cr_skipBlanks(p, s);
p->this->start = s;
s = cr_nextLine(p, s);
char *z = s;
if (s[-1] == '\n') s--;
while(s[-1] == ' ' || s[-1]=='\t') s--;
while(s[-1] == '=' ) s--;
if (p->this->start < s){
p->cursor = z;
p->this->kind = KIND_HEADING;
p->this->end = s;
p->this->level = level;
p->this->flags |= flags;
return 1;
}
return 0;
}
//}}}
static int isHorizontalRule(Parser *p){//{{{
|
| ︙ | ︙ | |||
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 |
cr_render(p, p->previous);
p->previous = p->this;
p->this = pool_new(p);
}
}
//}}}
char *wiki_render_creole(Renderer *r, char *z){//{{{
Parser parser;
Parser *p = &parser;
| > > | 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 |
cr_render(p, p->previous);
p->previous = p->this;
p->this = pool_new(p);
}
}
//}}}
//}}}
char *wiki_render_creole(Renderer *r, char *z){//{{{
Parser parser;
Parser *p = &parser;
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
78 79 80 81 82 83 84 |
/*
** Draw the header.
*/
void style_header(const char *zTitleFormat, ...){
va_list ap;
char *zTitle;
| | | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
/*
** Draw the header.
*/
void style_header(const char *zTitleFormat, ...){
va_list ap;
char *zTitle;
const char *zHeader = db_get("header", (char*)zDefaultHeader);
login_check_credentials();
va_start(ap, zTitleFormat);
zTitle = vmprintf(zTitleFormat, ap);
va_end(ap);
cgi_destination(CGI_HEADER);
if( g.thTrace ) Th_Trace("BEGIN_HEADER<br />\n", -1);
/* Generate the header up through the main menu */
Th_Store("project_name", db_get("project-name","Unnamed Fossil Project"));
Th_Store("title", zTitle);
Th_Store("baseurl", g.zBaseURL);
Th_Store("index_page", db_get("index-page","/home"));
|
| ︙ | ︙ | |||
116 117 118 119 120 121 122 |
/*
** Draw the footer at the bottom of the page.
*/
void style_footer(void){
const char *zFooter;
if( !headerHasBeenGenerated ) return;
| | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
/*
** Draw the footer at the bottom of the page.
*/
void style_footer(void){
const char *zFooter;
if( !headerHasBeenGenerated ) return;
/* Go back and put the submenu at the top of the page. We delay the
** creation of the submenu until the end so that we can add elements
** to the submenu while generating page text.
*/
cgi_destination(CGI_HEADER);
if( nSubmenu>0 ){
int i;
|
| ︙ | ︙ | |||
146 147 148 149 150 151 152 |
/* Put the footer at the bottom of the page.
*/
@ </div>
zFooter = db_get("footer", (char*)zDefaultFooter);
if( g.thTrace ) Th_Trace("BEGIN_FOOTER<br />\n", -1);
Th_Render(zFooter);
if( g.thTrace ) Th_Trace("END_FOOTER<br />\n", -1);
| | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
/* Put the footer at the bottom of the page.
*/
@ </div>
zFooter = db_get("footer", (char*)zDefaultFooter);
if( g.thTrace ) Th_Trace("BEGIN_FOOTER<br />\n", -1);
Th_Render(zFooter);
if( g.thTrace ) Th_Trace("END_FOOTER<br />\n", -1);
/* Render trace log if TH1 tracing is enabled. */
if( g.thTrace ){
cgi_append_content("<font color=\"red\"><hr>\n", -1);
cgi_append_content(blob_str(&g.thLog), blob_size(&g.thLog));
cgi_append_content("</font>\n", -1);
}
}
|
| ︙ | ︙ | |||
177 178 179 180 181 182 183 | @ </td></tr></table> } /* @-comment: // */ /* ** The default page header. */ | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | @ </td></tr></table> } /* @-comment: // */ /* ** The default page header. */ const char zDefaultHeader[] = @ <html> @ <head> @ <title>$<project_name>: $<title></title> @ <link rel="alternate" type="application/rss+xml" title="RSS Feed" @ href="$baseurl/timeline.rss"> @ <link rel="stylesheet" href="$baseurl/style.css" type="text/css" @ media="screen"> |
| ︙ | ︙ | |||
234 235 236 237 238 239 240 | @ } @ </th1></div> ; /* ** The default page footer */ | | | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
@ }
@ </th1></div>
;
/*
** The default page footer
*/
const char zDefaultFooter[] =
@ <div class="footer">
@ Fossil version $manifest_version $manifest_date
@ </div>
@ </body></html>
;
/*
** The default Cascading Style Sheet.
*/
const char zDefaultCSS[] =
@ /* General settings for the entire page */
@ body {
@ margin: 0ex 1ex;
@ padding: 0px;
@ background-color: white;
@ font-family: "sans serif";
@ }
|
| ︙ | ︙ | |||
362 363 364 365 366 367 368 |
@ }
@
@ /* Make the links in the footer less ugly... */
@ div.footer a { color: white; }
@ div.footer a:link { color: white; }
@ div.footer a:visited { color: white; }
@ div.footer a:hover { background-color: white; color: #558195; }
| | | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
@ }
@
@ /* Make the links in the footer less ugly... */
@ div.footer a { color: white; }
@ div.footer a:link { color: white; }
@ div.footer a:visited { color: white; }
@ div.footer a:hover { background-color: white; color: #558195; }
@
@ /* <verbatim> blocks */
@ pre.verbatim {
@ background-color: #f5f5f5;
@ padding: 0.5em;
@}
@
@ /* The label/value pairs on (for example) the ci page */
|
| ︙ | ︙ | |||
389 390 391 392 393 394 395 |
@ background: #ffff00;
@ border: 1px solid #ff0000;
@ }
@
@ div.miniform {
@ font-size: smaller;
@ margin: 8px;
| | | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
@ background: #ffff00;
@ border: 1px solid #ff0000;
@ }
@
@ div.miniform {
@ font-size: smaller;
@ margin: 8px;
@ }
@
@ table.fossil_db_generic_query_view {
@ border-spacing: 0px;
@ border: 1px solid black;
@ }
@ table.fossil_db_generic_query_view td {
@ padding: 2px 1em 2px 1em;
|
| ︙ | ︙ | |||
411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
@ background: #e5e5e5;
@ }
@ table.fossil_db_generic_query_view tr.header {
@ background: #558195;
@ font-size: 1.5em;
@ color: #ffffff;
@ }
;
/*
** WEBPAGE: style.css
*/
void page_style_css(void){
char *zCSS = 0;
| > > > > > > > > > > > > > > > > > > > > > | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
@ background: #e5e5e5;
@ }
@ table.fossil_db_generic_query_view tr.header {
@ background: #558195;
@ font-size: 1.5em;
@ color: #ffffff;
@ }
@ .creoletable {
@ border: 1px solid #666666;
@ border-spacing: 0;
@ margin: 1.5em 2em 1.8em 2em;
@ }
@ .creoletable * tr th {
@ font-size: 100%;
@ padding: .5em .7em .5em .7em;
@ border-left: 1px solid #666666;
@ background-color: #558195;
@ vertical-align: bottom;
@ color: white;
@ empty-cells: show;
@ }
@ .creoletable * tr td {
@ padding: .4em .7em .45em .7em;
@ border-left: 1px solid #D9D9D9;
@ border-top: 1px solid #D9D9D9;
@ vertical-align: center;
@ empty-cells: show;
@ }
;
/*
** WEBPAGE: style.css
*/
void page_style_css(void){
char *zCSS = 0;
|
| ︙ | ︙ |