--- didiwiki-0.3/src/wiki.c 2004-08-10 23:39:24.000000000 +0800
+++ didiwiki/src/wiki.c 2004-09-02 10:10:56.000000000 +0800
@@ -214,7 +214,8 @@ wiki_print_data_as_html(HttpResponse *re
int strikethrough_on = 0;
int open_para = 0;
int pre_on = 0;
- int list_depth = 0;
+ int ulist_depth = 0;
+ int olist_depth = 0;
int table_on = 0;
q = p; /* p accumalates non marked up text, q is just a pointer
@@ -243,31 +244,65 @@ wiki_print_data_as_html(HttpResponse *re
while ( *line == '*' ) { line++; item_depth++; }
- if (item_depth < list_depth)
+ if (item_depth < ulist_depth)
{
- for (i = 0; i < (list_depth - item_depth); i++)
+ for (i = 0; i < (ulist_depth - item_depth); i++)
http_response_printf(res, "\n");
}
else
{
- for (i = 0; i < (item_depth - list_depth); i++)
+ for (i = 0; i < (item_depth - ulist_depth); i++)
http_response_printf(res, "
\n");
}
http_response_printf(res, "- ");
- list_depth = item_depth;
+ ulist_depth = item_depth;
goto line_content; /* skip parsing any more initial chars */
}
- else if (list_depth)
+ else if (ulist_depth)
{
/* close current list */
- for (i=0; i\n");
- list_depth = 0;
+ ulist_depth = 0;
+ }
+
+ /* ordered list, extra checks avoid bolding */
+ if ( *line == '#' && ( *(line+1) == '#' || isspace(*(line+1)) ) )
+ {
+ int item_depth = 0;
+
+ while ( *line == '#' ) { line++; item_depth++; }
+
+ if (item_depth < olist_depth)
+ {
+ for (i = 0; i < (olist_depth - item_depth); i++)
+ http_response_printf(res, "\n");
+ }
+ else
+ {
+ for (i = 0; i < (item_depth - olist_depth); i++)
+ http_response_printf(res, "
\n");
+ }
+
+ http_response_printf(res, "- ");
+
+ olist_depth = item_depth;
+
+ goto line_content; /* skip parsing any more initial chars */
+ }
+ else if (olist_depth)
+ {
+ /* close current list */
+
+ for (i=0; i\n");
+
+ olist_depth = 0;
}
/* Tables */
@@ -491,7 +526,7 @@ wiki_print_data_as_html(HttpResponse *re
/* close any html tags that could be still open */
- if (list_depth)
+ if (ulist_depth || olist_depth)
http_response_printf(res, "
");
if (table_on)
@@ -511,8 +546,11 @@ wiki_print_data_as_html(HttpResponse *re
http_response_printf(res, "\n");
/* close any open lists */
- for (i=0; i\n");
+ /* close any open lists */
+ for (i=0; i\n");
/* close any open paras */
if (open_para)