Fossil SCM
* Added enumeration list support via the # character (identical to *). * Updated the wiki rules web page to reflect new enumeration list rules and terminated begining <li> tags with </li>.
Commit
2bb1d6469f96de4575aff0410a59d64f8fe0ee18
Parent
484c8f9f860a0e1…
2 files changed
+13
-14
+35
-10
+13
-14
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -630,18 +630,20 @@ | ||
| 630 | 630 | */ |
| 631 | 631 | void wikirules_page(void){ |
| 632 | 632 | style_header("Wiki Formatting Rules"); |
| 633 | 633 | @ <h2>Formatting Rule Summary</h2> |
| 634 | 634 | @ <ol> |
| 635 | - @ <li> Blank lines are paragraph breaks | |
| 636 | - @ <li> Bullets are "*" surrounded by two spaces at the beginning of the line. | |
| 637 | - @ <li> Enumeration items are a number surrounded by two space | |
| 638 | - @ at the beginning of a line. | |
| 639 | - @ <li> Indented pargraphs begin with a tab or two spaces. | |
| 640 | - @ <li> Hyperlinks are contained with square brackets: "[target]" | |
| 641 | - @ <li> Most ordinary HTML works. | |
| 642 | - @ <li> <verbatim> and <nowiki>. | |
| 635 | + @ <li>Blank lines are paragraph breaks</li> | |
| 636 | + @ <li>Bullets are "*" surrounded by two spaces at the beginning of the | |
| 637 | + @ line.</li> | |
| 638 | + @ <li>Enumeration items are "#" surrounded by two spaces at the beginning of | |
| 639 | + @ a line.</li> | |
| 640 | + @ <li>Indented pargraphs begin with a tab or two spaces.</li> | |
| 641 | + @ <li>Hyperlinks are contained with square brackets: "[target]" or | |
| 642 | + @ "[target|name]".</li> | |
| 643 | + @ <li>Most ordinary HTML works.</li> | |
| 644 | + @ <li><verbatim> and <nowiki>.</li> | |
| 643 | 645 | @ </ol> |
| 644 | 646 | @ <p>We call the first five rules above "wiki" formatting rules. The |
| 645 | 647 | @ last two rules are the HTML formatting rule.</p> |
| 646 | 648 | @ <h2>Formatting Rule Details</h2> |
| 647 | 649 | @ <ol> |
| @@ -653,16 +655,13 @@ | ||
| 653 | 655 | @ A bullet list item is a line that begins with a single "*" character |
| 654 | 656 | @ surrounded on |
| 655 | 657 | @ both sides by two or more spaces or by a tab. Only a single level |
| 656 | 658 | @ of bullet list is supported by wiki. For nested lists, use HTML.</p> |
| 657 | 659 | @ <li> <p><b>Enumeration Lists</b>. |
| 658 | - @ An enumeration list item is a line that begins | |
| 659 | - @ with one or more digits optionally | |
| 660 | - @ followed by a "." and is surrounded on both sides by two or more spaces or | |
| 661 | - @ by a tab. The number is significant and becomes the number shown | |
| 662 | - @ in the rendered enumeration item. Only a single level of enumeration | |
| 663 | - @ list is supported by wiki. For nested enumerations or for | |
| 660 | + @ An enumeration list item is a line that begins with a single "#" character | |
| 661 | + @ surrounded on both sides by two or more spaces or by a tab. Only a single | |
| 662 | + @ level of enumeration list is supported by wiki. For nested lists or for | |
| 664 | 663 | @ enumerations that count using letters or roman numerials, use HTML.</p> |
| 665 | 664 | @ <li> <p><b>Indented Paragraphs</b>. |
| 666 | 665 | @ Any paragraph that begins with two or more spaces or a tab and |
| 667 | 666 | @ which is not a bullet or enumeration list item is rendered |
| 668 | 667 | @ indented. Only a single level of indentation is supported by wiki; use |
| 669 | 668 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -630,18 +630,20 @@ | |
| 630 | */ |
| 631 | void wikirules_page(void){ |
| 632 | style_header("Wiki Formatting Rules"); |
| 633 | @ <h2>Formatting Rule Summary</h2> |
| 634 | @ <ol> |
| 635 | @ <li> Blank lines are paragraph breaks |
| 636 | @ <li> Bullets are "*" surrounded by two spaces at the beginning of the line. |
| 637 | @ <li> Enumeration items are a number surrounded by two space |
| 638 | @ at the beginning of a line. |
| 639 | @ <li> Indented pargraphs begin with a tab or two spaces. |
| 640 | @ <li> Hyperlinks are contained with square brackets: "[target]" |
| 641 | @ <li> Most ordinary HTML works. |
| 642 | @ <li> <verbatim> and <nowiki>. |
| 643 | @ </ol> |
| 644 | @ <p>We call the first five rules above "wiki" formatting rules. The |
| 645 | @ last two rules are the HTML formatting rule.</p> |
| 646 | @ <h2>Formatting Rule Details</h2> |
| 647 | @ <ol> |
| @@ -653,16 +655,13 @@ | |
| 653 | @ A bullet list item is a line that begins with a single "*" character |
| 654 | @ surrounded on |
| 655 | @ both sides by two or more spaces or by a tab. Only a single level |
| 656 | @ of bullet list is supported by wiki. For nested lists, use HTML.</p> |
| 657 | @ <li> <p><b>Enumeration Lists</b>. |
| 658 | @ An enumeration list item is a line that begins |
| 659 | @ with one or more digits optionally |
| 660 | @ followed by a "." and is surrounded on both sides by two or more spaces or |
| 661 | @ by a tab. The number is significant and becomes the number shown |
| 662 | @ in the rendered enumeration item. Only a single level of enumeration |
| 663 | @ list is supported by wiki. For nested enumerations or for |
| 664 | @ enumerations that count using letters or roman numerials, use HTML.</p> |
| 665 | @ <li> <p><b>Indented Paragraphs</b>. |
| 666 | @ Any paragraph that begins with two or more spaces or a tab and |
| 667 | @ which is not a bullet or enumeration list item is rendered |
| 668 | @ indented. Only a single level of indentation is supported by wiki; use |
| 669 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -630,18 +630,20 @@ | |
| 630 | */ |
| 631 | void wikirules_page(void){ |
| 632 | style_header("Wiki Formatting Rules"); |
| 633 | @ <h2>Formatting Rule Summary</h2> |
| 634 | @ <ol> |
| 635 | @ <li>Blank lines are paragraph breaks</li> |
| 636 | @ <li>Bullets are "*" surrounded by two spaces at the beginning of the |
| 637 | @ line.</li> |
| 638 | @ <li>Enumeration items are "#" surrounded by two spaces at the beginning of |
| 639 | @ a line.</li> |
| 640 | @ <li>Indented pargraphs begin with a tab or two spaces.</li> |
| 641 | @ <li>Hyperlinks are contained with square brackets: "[target]" or |
| 642 | @ "[target|name]".</li> |
| 643 | @ <li>Most ordinary HTML works.</li> |
| 644 | @ <li><verbatim> and <nowiki>.</li> |
| 645 | @ </ol> |
| 646 | @ <p>We call the first five rules above "wiki" formatting rules. The |
| 647 | @ last two rules are the HTML formatting rule.</p> |
| 648 | @ <h2>Formatting Rule Details</h2> |
| 649 | @ <ol> |
| @@ -653,16 +655,13 @@ | |
| 655 | @ A bullet list item is a line that begins with a single "*" character |
| 656 | @ surrounded on |
| 657 | @ both sides by two or more spaces or by a tab. Only a single level |
| 658 | @ of bullet list is supported by wiki. For nested lists, use HTML.</p> |
| 659 | @ <li> <p><b>Enumeration Lists</b>. |
| 660 | @ An enumeration list item is a line that begins with a single "#" character |
| 661 | @ surrounded on both sides by two or more spaces or by a tab. Only a single |
| 662 | @ level of enumeration list is supported by wiki. For nested lists or for |
| 663 | @ enumerations that count using letters or roman numerials, use HTML.</p> |
| 664 | @ <li> <p><b>Indented Paragraphs</b>. |
| 665 | @ Any paragraph that begins with two or more spaces or a tab and |
| 666 | @ which is not a bullet or enumeration list item is rendered |
| 667 | @ indented. Only a single level of indentation is supported by wiki; use |
| 668 |
+35
-10
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -329,14 +329,15 @@ | ||
| 329 | 329 | #define TOKEN_MARKUP 1 /* <...> */ |
| 330 | 330 | #define TOKEN_CHARACTER 2 /* "&" or "<" not part of markup */ |
| 331 | 331 | #define TOKEN_LINK 3 /* [...] */ |
| 332 | 332 | #define TOKEN_PARAGRAPH 4 /* blank lines */ |
| 333 | 333 | #define TOKEN_NEWLINE 5 /* A single "\n" */ |
| 334 | -#define TOKEN_BULLET 6 /* " * " */ | |
| 335 | -#define TOKEN_ENUM 7 /* " \(?\d+[.)]? " */ | |
| 336 | -#define TOKEN_INDENT 8 /* " " */ | |
| 337 | -#define TOKEN_TEXT 9 /* None of the above */ | |
| 334 | +#define TOKEN_BUL_LI 6 /* " * " */ | |
| 335 | +#define TOKEN_NUM_LI 7 /* " # " */ | |
| 336 | +#define TOKEN_ENUM 8 /* " \(?\d+[.)]? " */ | |
| 337 | +#define TOKEN_INDENT 9 /* " " */ | |
| 338 | +#define TOKEN_TEXT 10 /* None of the above */ | |
| 338 | 339 | |
| 339 | 340 | /* |
| 340 | 341 | ** State flags |
| 341 | 342 | */ |
| 342 | 343 | #define AT_NEWLINE 0x001 /* At start of a line */ |
| @@ -452,23 +453,23 @@ | ||
| 452 | 453 | return i>1 && z[i]==';'; |
| 453 | 454 | } |
| 454 | 455 | } |
| 455 | 456 | |
| 456 | 457 | /* |
| 457 | -** Check to see if the z[] string is the beginning of a wiki bullet. | |
| 458 | +** Check to see if the z[] string is the beginning of a wiki list item. | |
| 458 | 459 | ** If it is, return the length of the bullet text. Otherwise return 0. |
| 459 | 460 | */ |
| 460 | -static int bulletLength(const char *z){ | |
| 461 | +static int listItemLength(const char *z, const char listChar){ | |
| 461 | 462 | int i, n; |
| 462 | 463 | n = 0; |
| 463 | 464 | i = 0; |
| 464 | 465 | while( z[n]==' ' || z[n]=='\t' ){ |
| 465 | 466 | if( z[n]=='\t' ) i++; |
| 466 | 467 | i++; |
| 467 | 468 | n++; |
| 468 | 469 | } |
| 469 | - if( i<2 || z[n]!='*' ) return 0; | |
| 470 | + if( i<2 || z[n]!=listChar ) return 0; | |
| 470 | 471 | n++; |
| 471 | 472 | i = 0; |
| 472 | 473 | while( z[n]==' ' || z[n]=='\t' ){ |
| 473 | 474 | if( z[n]=='\t' ) i++; |
| 474 | 475 | i++; |
| @@ -578,13 +579,18 @@ | ||
| 578 | 579 | *pTokenType = TOKEN_NEWLINE; |
| 579 | 580 | return 1; |
| 580 | 581 | } |
| 581 | 582 | } |
| 582 | 583 | if( (p->state & AT_NEWLINE)!=0 && isspace(z[0]) ){ |
| 583 | - n = bulletLength(z); | |
| 584 | + n = listItemLength(z, '*'); | |
| 585 | + if( n>0 ){ | |
| 586 | + *pTokenType = TOKEN_BUL_LI; | |
| 587 | + return n; | |
| 588 | + } | |
| 589 | + n = listItemLength(z, '#'); | |
| 584 | 590 | if( n>0 ){ |
| 585 | - *pTokenType = TOKEN_BULLET; | |
| 591 | + *pTokenType = TOKEN_NUM_LI; | |
| 586 | 592 | return n; |
| 587 | 593 | } |
| 588 | 594 | n = enumLength(z); |
| 589 | 595 | if( n>0 ){ |
| 590 | 596 | *pTokenType = TOKEN_ENUM; |
| @@ -1059,11 +1065,11 @@ | ||
| 1059 | 1065 | case TOKEN_NEWLINE: { |
| 1060 | 1066 | blob_append(p->pOut, "\n", 1); |
| 1061 | 1067 | p->state |= AT_NEWLINE; |
| 1062 | 1068 | break; |
| 1063 | 1069 | } |
| 1064 | - case TOKEN_BULLET: { | |
| 1070 | + case TOKEN_BUL_LI: { | |
| 1065 | 1071 | if( inlineOnly ){ |
| 1066 | 1072 | blob_append(p->pOut, " • ", -1); |
| 1067 | 1073 | }else{ |
| 1068 | 1074 | if( p->wikiList!=MARKUP_UL ){ |
| 1069 | 1075 | if( p->wikiList ){ |
| @@ -1070,10 +1076,29 @@ | ||
| 1070 | 1076 | popStackToTag(p, p->wikiList); |
| 1071 | 1077 | } |
| 1072 | 1078 | pushStack(p, MARKUP_UL); |
| 1073 | 1079 | blob_append(p->pOut, "<ul>", 4); |
| 1074 | 1080 | p->wikiList = MARKUP_UL; |
| 1081 | + } | |
| 1082 | + popStackToTag(p, MARKUP_LI); | |
| 1083 | + startAutoParagraph(p); | |
| 1084 | + pushStack(p, MARKUP_LI); | |
| 1085 | + blob_append(p->pOut, "<li>", 4); | |
| 1086 | + } | |
| 1087 | + break; | |
| 1088 | + } | |
| 1089 | + case TOKEN_NUM_LI: { | |
| 1090 | + if( inlineOnly ){ | |
| 1091 | + blob_append(p->pOut, " # ", -1); | |
| 1092 | + }else{ | |
| 1093 | + if( p->wikiList!=MARKUP_OL ){ | |
| 1094 | + if( p->wikiList ){ | |
| 1095 | + popStackToTag(p, p->wikiList); | |
| 1096 | + } | |
| 1097 | + pushStack(p, MARKUP_OL); | |
| 1098 | + blob_append(p->pOut, "<ol>", 4); | |
| 1099 | + p->wikiList = MARKUP_OL; | |
| 1075 | 1100 | } |
| 1076 | 1101 | popStackToTag(p, MARKUP_LI); |
| 1077 | 1102 | startAutoParagraph(p); |
| 1078 | 1103 | pushStack(p, MARKUP_LI); |
| 1079 | 1104 | blob_append(p->pOut, "<li>", 4); |
| 1080 | 1105 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -329,14 +329,15 @@ | |
| 329 | #define TOKEN_MARKUP 1 /* <...> */ |
| 330 | #define TOKEN_CHARACTER 2 /* "&" or "<" not part of markup */ |
| 331 | #define TOKEN_LINK 3 /* [...] */ |
| 332 | #define TOKEN_PARAGRAPH 4 /* blank lines */ |
| 333 | #define TOKEN_NEWLINE 5 /* A single "\n" */ |
| 334 | #define TOKEN_BULLET 6 /* " * " */ |
| 335 | #define TOKEN_ENUM 7 /* " \(?\d+[.)]? " */ |
| 336 | #define TOKEN_INDENT 8 /* " " */ |
| 337 | #define TOKEN_TEXT 9 /* None of the above */ |
| 338 | |
| 339 | /* |
| 340 | ** State flags |
| 341 | */ |
| 342 | #define AT_NEWLINE 0x001 /* At start of a line */ |
| @@ -452,23 +453,23 @@ | |
| 452 | return i>1 && z[i]==';'; |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | /* |
| 457 | ** Check to see if the z[] string is the beginning of a wiki bullet. |
| 458 | ** If it is, return the length of the bullet text. Otherwise return 0. |
| 459 | */ |
| 460 | static int bulletLength(const char *z){ |
| 461 | int i, n; |
| 462 | n = 0; |
| 463 | i = 0; |
| 464 | while( z[n]==' ' || z[n]=='\t' ){ |
| 465 | if( z[n]=='\t' ) i++; |
| 466 | i++; |
| 467 | n++; |
| 468 | } |
| 469 | if( i<2 || z[n]!='*' ) return 0; |
| 470 | n++; |
| 471 | i = 0; |
| 472 | while( z[n]==' ' || z[n]=='\t' ){ |
| 473 | if( z[n]=='\t' ) i++; |
| 474 | i++; |
| @@ -578,13 +579,18 @@ | |
| 578 | *pTokenType = TOKEN_NEWLINE; |
| 579 | return 1; |
| 580 | } |
| 581 | } |
| 582 | if( (p->state & AT_NEWLINE)!=0 && isspace(z[0]) ){ |
| 583 | n = bulletLength(z); |
| 584 | if( n>0 ){ |
| 585 | *pTokenType = TOKEN_BULLET; |
| 586 | return n; |
| 587 | } |
| 588 | n = enumLength(z); |
| 589 | if( n>0 ){ |
| 590 | *pTokenType = TOKEN_ENUM; |
| @@ -1059,11 +1065,11 @@ | |
| 1059 | case TOKEN_NEWLINE: { |
| 1060 | blob_append(p->pOut, "\n", 1); |
| 1061 | p->state |= AT_NEWLINE; |
| 1062 | break; |
| 1063 | } |
| 1064 | case TOKEN_BULLET: { |
| 1065 | if( inlineOnly ){ |
| 1066 | blob_append(p->pOut, " • ", -1); |
| 1067 | }else{ |
| 1068 | if( p->wikiList!=MARKUP_UL ){ |
| 1069 | if( p->wikiList ){ |
| @@ -1070,10 +1076,29 @@ | |
| 1070 | popStackToTag(p, p->wikiList); |
| 1071 | } |
| 1072 | pushStack(p, MARKUP_UL); |
| 1073 | blob_append(p->pOut, "<ul>", 4); |
| 1074 | p->wikiList = MARKUP_UL; |
| 1075 | } |
| 1076 | popStackToTag(p, MARKUP_LI); |
| 1077 | startAutoParagraph(p); |
| 1078 | pushStack(p, MARKUP_LI); |
| 1079 | blob_append(p->pOut, "<li>", 4); |
| 1080 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -329,14 +329,15 @@ | |
| 329 | #define TOKEN_MARKUP 1 /* <...> */ |
| 330 | #define TOKEN_CHARACTER 2 /* "&" or "<" not part of markup */ |
| 331 | #define TOKEN_LINK 3 /* [...] */ |
| 332 | #define TOKEN_PARAGRAPH 4 /* blank lines */ |
| 333 | #define TOKEN_NEWLINE 5 /* A single "\n" */ |
| 334 | #define TOKEN_BUL_LI 6 /* " * " */ |
| 335 | #define TOKEN_NUM_LI 7 /* " # " */ |
| 336 | #define TOKEN_ENUM 8 /* " \(?\d+[.)]? " */ |
| 337 | #define TOKEN_INDENT 9 /* " " */ |
| 338 | #define TOKEN_TEXT 10 /* None of the above */ |
| 339 | |
| 340 | /* |
| 341 | ** State flags |
| 342 | */ |
| 343 | #define AT_NEWLINE 0x001 /* At start of a line */ |
| @@ -452,23 +453,23 @@ | |
| 453 | return i>1 && z[i]==';'; |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | /* |
| 458 | ** Check to see if the z[] string is the beginning of a wiki list item. |
| 459 | ** If it is, return the length of the bullet text. Otherwise return 0. |
| 460 | */ |
| 461 | static int listItemLength(const char *z, const char listChar){ |
| 462 | int i, n; |
| 463 | n = 0; |
| 464 | i = 0; |
| 465 | while( z[n]==' ' || z[n]=='\t' ){ |
| 466 | if( z[n]=='\t' ) i++; |
| 467 | i++; |
| 468 | n++; |
| 469 | } |
| 470 | if( i<2 || z[n]!=listChar ) return 0; |
| 471 | n++; |
| 472 | i = 0; |
| 473 | while( z[n]==' ' || z[n]=='\t' ){ |
| 474 | if( z[n]=='\t' ) i++; |
| 475 | i++; |
| @@ -578,13 +579,18 @@ | |
| 579 | *pTokenType = TOKEN_NEWLINE; |
| 580 | return 1; |
| 581 | } |
| 582 | } |
| 583 | if( (p->state & AT_NEWLINE)!=0 && isspace(z[0]) ){ |
| 584 | n = listItemLength(z, '*'); |
| 585 | if( n>0 ){ |
| 586 | *pTokenType = TOKEN_BUL_LI; |
| 587 | return n; |
| 588 | } |
| 589 | n = listItemLength(z, '#'); |
| 590 | if( n>0 ){ |
| 591 | *pTokenType = TOKEN_NUM_LI; |
| 592 | return n; |
| 593 | } |
| 594 | n = enumLength(z); |
| 595 | if( n>0 ){ |
| 596 | *pTokenType = TOKEN_ENUM; |
| @@ -1059,11 +1065,11 @@ | |
| 1065 | case TOKEN_NEWLINE: { |
| 1066 | blob_append(p->pOut, "\n", 1); |
| 1067 | p->state |= AT_NEWLINE; |
| 1068 | break; |
| 1069 | } |
| 1070 | case TOKEN_BUL_LI: { |
| 1071 | if( inlineOnly ){ |
| 1072 | blob_append(p->pOut, " • ", -1); |
| 1073 | }else{ |
| 1074 | if( p->wikiList!=MARKUP_UL ){ |
| 1075 | if( p->wikiList ){ |
| @@ -1070,10 +1076,29 @@ | |
| 1076 | popStackToTag(p, p->wikiList); |
| 1077 | } |
| 1078 | pushStack(p, MARKUP_UL); |
| 1079 | blob_append(p->pOut, "<ul>", 4); |
| 1080 | p->wikiList = MARKUP_UL; |
| 1081 | } |
| 1082 | popStackToTag(p, MARKUP_LI); |
| 1083 | startAutoParagraph(p); |
| 1084 | pushStack(p, MARKUP_LI); |
| 1085 | blob_append(p->pOut, "<li>", 4); |
| 1086 | } |
| 1087 | break; |
| 1088 | } |
| 1089 | case TOKEN_NUM_LI: { |
| 1090 | if( inlineOnly ){ |
| 1091 | blob_append(p->pOut, " # ", -1); |
| 1092 | }else{ |
| 1093 | if( p->wikiList!=MARKUP_OL ){ |
| 1094 | if( p->wikiList ){ |
| 1095 | popStackToTag(p, p->wikiList); |
| 1096 | } |
| 1097 | pushStack(p, MARKUP_OL); |
| 1098 | blob_append(p->pOut, "<ol>", 4); |
| 1099 | p->wikiList = MARKUP_OL; |
| 1100 | } |
| 1101 | popStackToTag(p, MARKUP_LI); |
| 1102 | startAutoParagraph(p); |
| 1103 | pushStack(p, MARKUP_LI); |
| 1104 | blob_append(p->pOut, "<li>", 4); |
| 1105 |