Please, find attached a patch that allows to use HTML comments of the form <!-- ..... --> in fossil wiki markup. This feature is especially handy for embedded documentations written using a text editor of choice. Comments allow to annotate wiki sources in meaningful way, comment out portions of the text, keep TODO notes, etc. I hope the patch does not break anything.
--Leo--
#### Fossil-SCM patch against trunk commit: artifact: 937514b96854b8ba378850ebab10cd893fed5d75 size: 22483 bytes tags: trunk type: Check-in by drh on 2012-02-11 18:25:16 comment: Further diff enhancements: Allow up to two diff-marks per line on a side-by-side diff. #### Index: src/wikiformat.c ================================================================== --- src/wikiformat.c~0 2012-02-12 12:18:07.000000000 -0500 +++ src/wikiformat.c 2012-02-12 11:06:45.000000000 -0500 @@ -404,10 +404,34 @@ static int wikiUsesHtml(void){ static int r = -1; if( r<0 ) r = db_get_boolean("wiki-use-html", 0); return r; } +/** Deals with HTML comments <!--...--> + * z points to '<' char. Returns number of chars in the HTML comment + * or -1 if markup is not a comment. + */ +static int markupLength_comment(const char *z){ + if( strncmp(z, "<!--", 4) == 0 ){ + int n= 4; /* points one after "<!--" */ + char c; + while( 1 ){ + for( c=z[n]; c && c!='-'; c=z[++n] ); /* find next '-' */ + if( c=='-' ){ + if( strncmp(&z[n], "-->", 3) ){ + return n + 3; + }else{ + n++; + } + }else{ + return -1; + } + } + } + return -1; +} + /* ** z points to a "<" character. Check to see if this is the start of ** a valid markup. If it is, return the total number of characters in ** the markup including the initial "<" and the terminating ">". If ** it is not well-formed markup, return 0. @@ -596,10 +620,14 @@ static int linkLength(const char *z){ ** characters in that token. Write the token type into *pTokenType. */ static int nextWikiToken(const char *z, Renderer *p, int *pTokenType){ int n; if( z[0]=='<' ){ + if( (n=markupLength_comment(z)) > 0 ){ + *pTokenType= TOKEN_RAW; + return n; + } n = markupLength(z); if( n>0 ){ *pTokenType = TOKEN_MARKUP; return n; }else{ #EoF
_______________________________________________ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users