Differences From:
File
src/wikiformat.c
part of check-in
[083cad82ff]
- rolled back my last commit for stripping P tags around UL/OL, which had broken logic.
by
stephan on
2009-12-08 10:10:04.
Also file
src/wikiformat.c
part of check-in
[6f0df6c741]
- Fixed the insertion of invalid P tags inside of UL and OL elements when autoparagraph is on. Bug was reported on the fossil mailing list by Stephan Beal.
by
jeremy_c on
2009-12-07 20:20:22.
[view]
To:
File
src/wikiformat.c
part of check-in
[2bb1d6469f]
- - Added enumeration list support via the # character (identical to *).
- Updated the wiki rules web page to reflect new enumeration list rules and terminated begining
- tags with
.
by
jeremy_c on
2009-12-09 14:39:20.
Also file
src/wikiformat.c
part of check-in
[1c2d878d12]
- Merge with trunk
by
btheado on
2009-12-13 01:16:13.
[view]
@@ -330,12 +330,13 @@
#define TOKEN_CHARACTER 2 /* "&" or "<" not part of markup */
#define TOKEN_LINK 3 /* [...] */
#define TOKEN_PARAGRAPH 4 /* blank lines */
#define TOKEN_NEWLINE 5 /* A single "\n" */
-#define TOKEN_BULLET 6 /* " * " */
-#define TOKEN_ENUM 7 /* " \(?\d+[.)]? " */
-#define TOKEN_INDENT 8 /* " " */
-#define TOKEN_TEXT 9 /* None of the above */
+#define TOKEN_BUL_LI 6 /* " * " */
+#define TOKEN_NUM_LI 7 /* " # " */
+#define TOKEN_ENUM 8 /* " \(?\d+[.)]? " */
+#define TOKEN_INDENT 9 /* " " */
+#define TOKEN_TEXT 10 /* None of the above */
/*
** State flags
*/
@@ -453,12 +454,12 @@
}
}
/*
-** Check to see if the z[] string is the beginning of a wiki bullet.
+** Check to see if the z[] string is the beginning of a wiki list item.
** If it is, return the length of the bullet text. Otherwise return 0.
*/
-static int bulletLength(const char *z){
+static int listItemLength(const char *z, const char listChar){
int i, n;
n = 0;
i = 0;
while( z[n]==' ' || z[n]=='\t' ){
@@ -465,9 +466,9 @@
if( z[n]=='\t' ) i++;
i++;
n++;
}
- if( i<2 || z[n]!='*' ) return 0;
+ if( i<2 || z[n]!=listChar ) return 0;
n++;
i = 0;
while( z[n]==' ' || z[n]=='\t' ){
if( z[n]=='\t' ) i++;
@@ -579,11 +580,16 @@
return 1;
}
}
if( (p->state & AT_NEWLINE)!=0 && isspace(z[0]) ){
- n = bulletLength(z);
+ n = listItemLength(z, '*');
+ if( n>0 ){
+ *pTokenType = TOKEN_BUL_LI;
+ return n;
+ }
+ n = listItemLength(z, '#');
if( n>0 ){
- *pTokenType = TOKEN_BULLET;
+ *pTokenType = TOKEN_NUM_LI;
return n;
}
n = enumLength(z);
if( n>0 ){
@@ -1060,9 +1066,9 @@
blob_append(p->pOut, "\n", 1);
p->state |= AT_NEWLINE;
break;
}
- case TOKEN_BULLET: {
+ case TOKEN_BUL_LI: {
if( inlineOnly ){
blob_append(p->pOut, " • ", -1);
}else{
if( p->wikiList!=MARKUP_UL ){
@@ -1071,8 +1077,27 @@
}
pushStack(p, MARKUP_UL);
blob_append(p->pOut, "<ul>", 4);
p->wikiList = MARKUP_UL;
+ }
+ popStackToTag(p, MARKUP_LI);
+ startAutoParagraph(p);
+ pushStack(p, MARKUP_LI);
+ blob_append(p->pOut, "<li>", 4);
+ }
+ break;
+ }
+ case TOKEN_NUM_LI: {
+ if( inlineOnly ){
+ blob_append(p->pOut, " # ", -1);
+ }else{
+ if( p->wikiList!=MARKUP_OL ){
+ if( p->wikiList ){
+ popStackToTag(p, p->wikiList);
+ }
+ pushStack(p, MARKUP_OL);
+ blob_append(p->pOut, "<ol>", 4);
+ p->wikiList = MARKUP_OL;
}
popStackToTag(p, MARKUP_LI);
startAutoParagraph(p);
pushStack(p, MARKUP_LI);