Diff
Not logged in

Differences From:

File src/wikiformat.c part of check-in [72e9eb6a0d] - Change • into • per ticket 2ed0655983b51af6. by drh on 2008-11-27 13:33:34. [view]

To:

File src/wikiformat.c part of check-in [47cc9dfec8] - Experimental - Pass < !-- --> comments through the wiki unchanged unless inside a < verbatim > block in which case it is htmlized. Also pass < span > tags, treating them as font markup. These changes make it easier to convert existing html pages and specifically allow the inclusion of license text in pages derived from copyright material. by robert on 2009-04-27 08:43:38. [view]

@@ -190,21 +190,22 @@
 #define MARKUP_PRE              32
 #define MARKUP_S                33
 #define MARKUP_SAMP             34
 #define MARKUP_SMALL            35
-#define MARKUP_STRIKE           36
-#define MARKUP_STRONG           37
-#define MARKUP_SUB              38
-#define MARKUP_SUP              39
-#define MARKUP_TABLE            40
-#define MARKUP_TD               41
-#define MARKUP_TH               42
-#define MARKUP_TR               43
-#define MARKUP_TT               44
-#define MARKUP_U                45
-#define MARKUP_UL               46
-#define MARKUP_VAR              47
-#define MARKUP_VERBATIM         48
+#define MARKUP_SPAN             36
+#define MARKUP_STRIKE           37
+#define MARKUP_STRONG           38
+#define MARKUP_SUB              39
+#define MARKUP_SUP              40
+#define MARKUP_TABLE            41
+#define MARKUP_TD               42
+#define MARKUP_TH               43
+#define MARKUP_TR               44
+#define MARKUP_TT               45
+#define MARKUP_U                46
+#define MARKUP_UL               47
+#define MARKUP_VAR              48
+#define MARKUP_VERBATIM         49
 
 /*
 ** The various markup is divided into the following types:
 */
@@ -277,8 +278,9 @@
  { "pre",           MARKUP_PRE,          MUTYPE_BLOCK,         0  },
  { "s",             MARKUP_S,            MUTYPE_FONT,          0  },
  { "samp",          MARKUP_SAMP,         MUTYPE_FONT,          0  },
  { "small",         MARKUP_SMALL,        MUTYPE_FONT,          0  },
+ { "span",          MARKUP_SPAN,         MUTYPE_FONT,          0  },
  { "strike",        MARKUP_STRIKE,       MUTYPE_FONT,          0  },
  { "strong",        MARKUP_STRONG,       MUTYPE_FONT,          0  },
  { "sub",           MARKUP_SUB,          MUTYPE_FONT,          0  },
  { "sup",           MARKUP_SUP,          MUTYPE_FONT,          0  },
@@ -333,9 +335,10 @@
 #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_COMMENT       9    /* <!-- --> */
+#define TOKEN_TEXT         10    /* None of the above */
 
 /*
 ** State flags
 */
@@ -377,8 +380,26 @@
 */
 static int markupLength(const char *z){
   int n = 1;
   int inparen = 0;
+
+  // is a comment - if valid return n else return 0
+  if( z[n]=='!' ){
+    n++;
+    if (z[n]!='-') return 0;
+    n++;
+    if (z[n]!='-') return 0;
+    n++;
+    while (z[n]){
+      while (z[n] && z[n]!='>') n++;
+      if (!z[n]) return 0;
+      n++;
+      if(n>3 && z[n-3]=='-' && z[n-2]=='-')
+        return (n>7) ? n : 0;
+    }
+    return 0;
+  }
+
   if( z[n]=='/' ){ n++; }
   if( !isalpha(z[n]) ) return 0;
   while( isalnum(z[n]) ){ n++; }
   if( z[n]!='>' && !isspace(z[n]) ) return 0;
@@ -555,11 +576,17 @@
 static int nextToken(const char *z, Renderer *p, int *pTokenType){
   int n;
   if( z[0]=='<' ){
     n = markupLength(z);
-    if( n>0 ){
-      *pTokenType = TOKEN_MARKUP;
-      return n;
+
+    if( n>1 ){
+      if (z[1]=='!'){
+        *pTokenType = TOKEN_COMMENT;
+        return n;
+      } else {
+        *pTokenType = TOKEN_MARKUP;
+        return n;
+      }
     }else{
       *pTokenType = TOKEN_CHARACTER;
       return 1;
     }
@@ -1023,8 +1050,17 @@
   while( z[0] ){
     n = nextToken(z, p, &tokenType);
     p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
     switch( tokenType ){
+
+      case TOKEN_COMMENT: {
+        if (p->inVerbatim){
+          blob_append(p->pOut, htmlize(z, n), -1);
+        } else {
+          blob_append(p->pOut, z, n);
+        }
+        break;
+      }
       case TOKEN_PARAGRAPH: {
         if( inlineOnly ){
           /* blob_append(p->pOut, " &para; ", -1); */
           blob_append(p->pOut, " &nbsp;&nbsp; ", -1);