Fork de wikipp, le moteur de wiki en c++, basé sur cppcms. Le fork ajoute la langue française
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

discount.patch 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Common subdirectories: discount-2.0.3/Plan9 and discount-2.0.3-side/Plan9
  2. Common subdirectories: discount-2.0.3/tests and discount-2.0.3-side/tests
  3. diff -u discount-2.0.3/toc.c discount-2.0.3-side/toc.c
  4. --- discount-2.0.3/toc.c 2010-11-27 08:44:44.000000000 +0200
  5. +++ discount-2.0.3-side/toc.c 2010-12-31 18:25:17.000000000 +0200
  6. @@ -21,6 +21,7 @@
  7. {
  8. Paragraph *tp, *srcp;
  9. int last_hnumber = 0;
  10. + int last_limit = 6;
  11. Cstring res;
  12. *doc = 0;
  13. @@ -31,6 +32,26 @@
  14. CREATE(res);
  15. RESERVE(res, 100);
  16. + /*
  17. + * Find the minimal heading level, useful in cases
  18. + * when h1 is already in use (like article title and
  19. + * in markdown only h2, h3 or even higher are used
  20. + *
  21. + * So list nesting would be done from min_header
  22. + */
  23. + for ( tp = p->code; tp ; tp = tp->next ) {
  24. + if ( tp->typ == SOURCE ) {
  25. + for ( srcp = tp->down; srcp; srcp = srcp->next ) {
  26. + if ( srcp->typ == HDR && srcp->text ) {
  27. + if(srcp->hnumber < last_limit + 1)
  28. + last_limit = srcp->hnumber - 1;
  29. + }
  30. + }
  31. + }
  32. + }
  33. +
  34. + last_hnumber = last_limit;
  35. +
  36. for ( tp = p->code; tp ; tp = tp->next ) {
  37. if ( tp->typ == SOURCE ) {
  38. for ( srcp = tp->down; srcp; srcp = srcp->next ) {
  39. @@ -45,7 +66,7 @@
  40. while ( srcp->hnumber > last_hnumber ) {
  41. Csprintf(&res, "%*s%s<ul>\n", last_hnumber, "",
  42. - last_hnumber ? "<li>" : "");
  43. + ( last_hnumber != last_limit )? "<li>" : "");
  44. ++last_hnumber;
  45. }
  46. Csprintf(&res, "%*s<li><a href=\"#", srcp->hnumber, "");
  47. @@ -61,9 +82,9 @@
  48. }
  49. }
  50. - while ( last_hnumber > 0 ) {
  51. + while ( last_hnumber > last_limit ) {
  52. --last_hnumber;
  53. - Csprintf(&res, last_hnumber ? "%*s</ul></li>\n" : "%*s</ul>\n", last_hnumber, "");
  54. + Csprintf(&res, (last_hnumber != last_limit ) ? "%*s</ul></li>\n" : "%*s</ul>\n", last_hnumber, "");
  55. }
  56. /* HACK ALERT! HACK ALERT! HACK ALERT! */
  57. *doc = T(res); /* we know that a T(Cstring) is a character pointer */
  58. Common subdirectories: discount-2.0.3/tools and discount-2.0.3-side/tools