cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1496960 - /cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
Date Wed, 26 Jun 2013 15:18:17 GMT
Author: dkulp
Date: Wed Jun 26 15:18:17 2013
New Revision: 1496960

URL: http://svn.apache.org/r1496960
Log:
Add support for snippet macro

Modified:
    cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java?rev=1496960&r1=1496959&r2=1496960&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java Wed Jun 26 15:18:17 2013
@@ -233,7 +233,11 @@ public class Page extends AbstractPage i
         if (idx != -1) {
             hasBlog = true;
         }
-        idx = c.indexOf("{code");
+        handleCode(c);
+    }
+
+    private void handleCode(String c) {
+        int idx = c.indexOf("{code");
         while (idx != -1) {
             String type = "java";
             idx += 5;
@@ -259,9 +263,35 @@ public class Page extends AbstractPage i
             }
             codeTypes.add(type);
             idx = c.indexOf("{code", idx + 1);
-        }
-    }
+        } 
+        idx = c.indexOf("{snippet");
+        while (idx != -1) {
+            String type = "java";
+            idx += 8;
+            if (c.charAt(idx) != '}') {
+                idx++;
+                int idx2 = c.indexOf('}', idx);
+                if (idx2 != -1) {
+                    String paramString = c.substring(idx, idx2);
+                    String params[] = paramString.split("\\||=");
+                    for (int x = 0; x < params.length; x++) {
+                        if ("lang".equals(params[x])) {
+                            type = params[x + 1];
+                            x++;
+                        } else if (CODE_TYPE_MAP.containsKey(params[x])) {
+                            type = params[x];
+                        }
+                    }
+                }
+            }
 
+            if (codeTypes == null) {
+                codeTypes = new CopyOnWriteArraySet<String>();
+            }
+            codeTypes.add(type);
+            idx = c.indexOf("{snippet", idx + 1);
+        } 
+    }
     
     public boolean hasChildrenOf(String t, int d) {
         if (childrenOf == null) {
@@ -467,6 +497,8 @@ public class Page extends AbstractPage i
                     state = State.BLOG_POSTS;
                 } else if ("code".equals(s)) {
                     state = State.CODE;
+                } else if ("snippet".equals(s)) {
+                    state = State.CODE;
                 } else if ("unmigrated-wiki-markup".equals(s)) {
                     System.out.println("WARNING: Page " + page.title + " has unmigrated wiki
content.");
                     //no idea what is in there, lets just turn on the code highlighting



Mime
View raw message