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>.

jeremy_c 2009-12-09 14:39 trunk
Commit 2bb1d6469f96de4575aff0410a59d64f8fe0ee18
2 files changed +13 -14 +35 -10
+13 -14
--- src/wiki.c
+++ src/wiki.c
@@ -630,18 +630,20 @@
630630
*/
631631
void wikirules_page(void){
632632
style_header("Wiki Formatting Rules");
633633
@ <h2>Formatting Rule Summary</h2>
634634
@ <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> &lt;verbatim&gt; and &lt;nowiki&gt;.
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>&lt;verbatim&gt; and &lt;nowiki&gt;.</li>
643645
@ </ol>
644646
@ <p>We call the first five rules above "wiki" formatting rules. The
645647
@ last two rules are the HTML formatting rule.</p>
646648
@ <h2>Formatting Rule Details</h2>
647649
@ <ol>
@@ -653,16 +655,13 @@
653655
@ A bullet list item is a line that begins with a single "*" character
654656
@ surrounded on
655657
@ both sides by two or more spaces or by a tab. Only a single level
656658
@ of bullet list is supported by wiki. For nested lists, use HTML.</p>
657659
@ <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
664663
@ enumerations that count using letters or roman numerials, use HTML.</p>
665664
@ <li> <p><b>Indented Paragraphs</b>.
666665
@ Any paragraph that begins with two or more spaces or a tab and
667666
@ which is not a bullet or enumeration list item is rendered
668667
@ indented. Only a single level of indentation is supported by wiki; use
669668
--- 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> &lt;verbatim&gt; and &lt;nowiki&gt;.
 
 
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>&lt;verbatim&gt; and &lt;nowiki&gt;.</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 @@
329329
#define TOKEN_MARKUP 1 /* <...> */
330330
#define TOKEN_CHARACTER 2 /* "&" or "<" not part of markup */
331331
#define TOKEN_LINK 3 /* [...] */
332332
#define TOKEN_PARAGRAPH 4 /* blank lines */
333333
#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 */
338339
339340
/*
340341
** State flags
341342
*/
342343
#define AT_NEWLINE 0x001 /* At start of a line */
@@ -452,23 +453,23 @@
452453
return i>1 && z[i]==';';
453454
}
454455
}
455456
456457
/*
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.
458459
** If it is, return the length of the bullet text. Otherwise return 0.
459460
*/
460
-static int bulletLength(const char *z){
461
+static int listItemLength(const char *z, const char listChar){
461462
int i, n;
462463
n = 0;
463464
i = 0;
464465
while( z[n]==' ' || z[n]=='\t' ){
465466
if( z[n]=='\t' ) i++;
466467
i++;
467468
n++;
468469
}
469
- if( i<2 || z[n]!='*' ) return 0;
470
+ if( i<2 || z[n]!=listChar ) return 0;
470471
n++;
471472
i = 0;
472473
while( z[n]==' ' || z[n]=='\t' ){
473474
if( z[n]=='\t' ) i++;
474475
i++;
@@ -578,13 +579,18 @@
578579
*pTokenType = TOKEN_NEWLINE;
579580
return 1;
580581
}
581582
}
582583
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, '#');
584590
if( n>0 ){
585
- *pTokenType = TOKEN_BULLET;
591
+ *pTokenType = TOKEN_NUM_LI;
586592
return n;
587593
}
588594
n = enumLength(z);
589595
if( n>0 ){
590596
*pTokenType = TOKEN_ENUM;
@@ -1059,11 +1065,11 @@
10591065
case TOKEN_NEWLINE: {
10601066
blob_append(p->pOut, "\n", 1);
10611067
p->state |= AT_NEWLINE;
10621068
break;
10631069
}
1064
- case TOKEN_BULLET: {
1070
+ case TOKEN_BUL_LI: {
10651071
if( inlineOnly ){
10661072
blob_append(p->pOut, " &bull; ", -1);
10671073
}else{
10681074
if( p->wikiList!=MARKUP_UL ){
10691075
if( p->wikiList ){
@@ -1070,10 +1076,29 @@
10701076
popStackToTag(p, p->wikiList);
10711077
}
10721078
pushStack(p, MARKUP_UL);
10731079
blob_append(p->pOut, "<ul>", 4);
10741080
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;
10751100
}
10761101
popStackToTag(p, MARKUP_LI);
10771102
startAutoParagraph(p);
10781103
pushStack(p, MARKUP_LI);
10791104
blob_append(p->pOut, "<li>", 4);
10801105
--- 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, " &bull; ", -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, " &bull; ", -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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button