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 [ecd1f09632] - Initial commit of Creole Wiki Parser extension. by robert on 2009-05-08 09:52:38. [view]

@@ -348,8 +348,9 @@
 
 /*
 ** Current state of the rendering engine
 */
+#if INTERFACE
 typedef struct Renderer Renderer;
 struct Renderer {
   Blob *pOut;                 /* Output appended to this blob */
   int state;                  /* Flag that govern rendering */
@@ -366,9 +367,9 @@
     short allowWiki;             /* ALLOW_WIKI if wiki allowed before tag */
     const char *zId;             /* ID attribute or NULL */
   } *aStack;
 };
-
+#endif
 
 /*
 ** 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
@@ -1007,8 +1008,9 @@
   if( p->nStack<=0 ) return 0;
   return aMarkup[p->aStack[p->nStack-1].iCode].iType;
 }
 
+
 /*
 ** Convert the wiki in z[] into html in the renderer p.  The
 ** renderer has already been initialized.
 **
@@ -1020,11 +1022,24 @@
   int n;
   int inlineOnly = (p->state & INLINE_MARKUP_ONLY)!=0;
 
   while( z[0] ){
+
+     /*
+     ** Additions to support creole parser
+     */
+
+    if (!p->inVerbatim && z[0]=='<' && z[1] == '<') {
+      z = wiki_render_macro(p, z, &tokenType);
+      if (tokenType) continue;
+    }
+    //
+
     n = nextToken(z, p, &tokenType);
     p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
+
     switch( tokenType ){
+
       case TOKEN_PARAGRAPH: {
         if( inlineOnly ){
           /* blob_append(p->pOut, " &para; ", -1); */
           blob_append(p->pOut, " &nbsp;&nbsp; ", -1);
@@ -1326,8 +1341,9 @@
   blob_append(renderer.pOut, "\n", 1);
   free(renderer.aStack);
 }
 
+
 /*
 ** COMMAND: test-wiki-render
 */
 void test_wiki_render(void){
@@ -1337,4 +1353,30 @@
   blob_read_from_file(&in, g.argv[2]);
   wiki_convert(&in, &out, 0);
   blob_write_to_file(&out, "-");
 }
+
+
+/*
+** Additions to support creole parser
+*/
+
+#ifndef HAVE_MACRO_EXTENSIONS
+char *wiki_render_macro(Renderer *p, char *z, int *tokenType) {
+  *tokenType = 0;
+  return z;
+}
+#endif
+
+int wf_linkLength(const char *z){
+  return linkLength(z);
+}
+void wf_openHyperlink(
+  Renderer *p,            /* Rendering context */
+  const char *zTarget,    /* Hyperlink traget; text within [...] */
+  char *zClose,           /* Write hyperlink closing text here */
+  int nClose              /* Bytes available in zClose[] */
+){
+  return openHyperlink(p, zTarget, zClose, nClose);
+}
+
+