WIP to fixing conversion scripts to use thoughtstorms lib, and moving SFWtools into...
authorPhil Jones <interstar@gmail.com>
Tue, 3 Jul 2018 07:02:17 +0000 (04:02 -0300)
committerPhil Jones <interstar@gmail.com>
Tue, 3 Jul 2018 07:02:17 +0000 (04:02 -0300)
python/conversion/wikish2md.py
python/thoughtstorms/README.md
python/thoughtstorms/thoughtstorms/SFWTools.py [moved from scripts/SFWTools.py with 100% similarity]
python/thoughtstorms/thoughtstorms/legacy.py [new file with mode: 0755]
python/thoughtstorms/thoughtstorms/txlib.py

index 2e24637..e5e80ba 100755 (executable)
@@ -2,10 +2,11 @@
 
 from sys import stdin, stdout, argv
 
-from thoughtstorms.txlib import Wikish2Markdown
+from thoughtstorms.legacy import Wikish2Markdown
 
 chef = Wikish2Markdown()
 
+
 for fName in argv[1:] :
        print fName
        oName = fName.split("/")[-1]
index 8463a14..84edeb4 100755 (executable)
@@ -8,7 +8,7 @@ This project breaks a number of components used in ThoughtStorms Wiki and associ
 
 ### Components :
 
-* PageStore
-* TSWiki
+* PageStore - a store of "pages" accessible by PageName. With extra functionality.
+* txlib - a library to transform Markdown + extra markup into HTML
 
 
diff --git a/python/thoughtstorms/thoughtstorms/legacy.py b/python/thoughtstorms/thoughtstorms/legacy.py
new file mode 100755 (executable)
index 0000000..9610975
--- /dev/null
@@ -0,0 +1,123 @@
+import re
+
+## Standard Wikish (the markup of UseMod)
+       
+class WikishProcessor :
+       
+    def __init__(self,env) :
+        self.blm = re.compile("^$")
+        self.hr = re.compile("----")
+        self.h6 = re.compile("^======(.+)======")
+        self.h5 = re.compile("^=====(.+)=====")
+        self.h4 = re.compile("^====(.+)====")
+        self.h3 = re.compile("^===(.+)===")
+        self.h2 = re.compile("^==(.+)==")
+        self.h1 = re.compile("^=(.+)=")
+        self.bold = re.compile("'''(.*?)'''")
+        self.italic = re.compile("''(.*?)''")
+        
+        self.sqrbrkt = re.compile("(\[\[(\S+?)\]\])")
+        self.extlink = re.compile("(\[(http\S+)\s+(.+?)\])")
+
+               #self.wikiword = re.compile("([A-Z][a-z]+([A-Z][a-z]+)+)")
+        
+        
+        self.indent = 0        
+                 
+    def line(self,l) : 
+        nl = l.strip()
+          
+        nl = self.blm.sub("<br/><br/>",nl)
+        nl = self.hr.sub("<hr>",nl)
+        nl = self.bold.sub(r"<b>\1</b>",nl)
+        nl = self.italic.sub(r"<i>\1</i>",nl)
+
+        nl = self.h6.sub(r"<h6>\1</h6>",nl)
+        nl = self.h5.sub(r"<h5>\1</h5>",nl)
+        nl = self.h4.sub(r"<h4>\1</h4>",nl)
+        nl = self.h3.sub(r"<h3>\1</h3>",nl)
+        nl = self.h2.sub(r"<h2>\1</h2>",nl)
+        nl = self.h1.sub(r"<h1>\1</h1>",nl)
+        nl = self.sqrbrkt.sub(r"""<a href="/view/\2">\2</a>""",nl)
+        nl = self.extlink.sub(r"""<a href="\2">\3</a>""",nl)
+
+        #nl = self.wikiword.sub(r"<a href='/view/\1' title='origin'>\1</a>",nl)        
+       
+            
+        return nl
+
+
+    def outlineFilter(self,l) :
+        if l[0] != "*" :
+            if self.indent > 0 :
+                s = "</ul>"*(self.indent)
+                self.indent = 0
+                l = s + "\n" + l
+            return l
+        
+        count = 0
+        while l[count] == "*" :
+            count=count+1
+        meat = l[count:]
+
+        if count == self.indent :
+            return " " * (self.indent+1) + "<li>" + meat + "</li>"
+        if count > self.indent :
+            self.indent = self.indent + 1
+            return "<ul>\n" + " " * (self.indent+1) + "<li>" + meat + "</li>"
+        s = "</ul>" * (self.indent + 1 - count) + "<li>" + meat + "</li>" 
+        self.indent = count
+        return s
+
+    def cook(self,p) :
+        lines = (self.line(wiki_filters(l)) for l in p.split("\n"))
+        lines = (self.outlineFilter(l) for l in lines)
+        lines = (social_filters() for l in lines)        
+        return "\n".join(lines)
+
+
+class Wikish2Markdown(WikishProcessor) :
+
+       def __init__(self,convert_tables=False) :
+               WikishProcessor.__init__(self)
+               self.convert_tables = convert_tables
+                 
+       def line(self,l) :      
+               nl = l.strip()
+               nl = self.blm.sub("\n",nl)
+        
+               nl = self.bold.sub(r"**\1**",nl)
+               nl = self.italic.sub(r"*\1*",nl)
+
+               nl = self.h6.sub(r"###### \1",nl)
+               nl = self.h5.sub(r"##### \1",nl)
+               nl = self.h4.sub(r"#### \1",nl)
+               nl = self.h3.sub(r"### \1",nl)
+               nl = self.h2.sub(r"## \1",nl)
+               nl = self.h1.sub(r"# \1",nl)
+        
+               nl = self.extlink.sub(r"""[\3](\2)""",nl)
+              
+
+               if self.convert_tables :
+                       if not self.tableMode :
+                           if self.doubleComma.findall(nl) :
+                               self.tableMode = True
+                               self.newTable = True
+                       
+                       if self.tableMode :
+                           if not self.doubleComma.findall(nl) :
+                               nl = nl + "\n\n"
+                               self.tableMode = False
+                           else :
+                               nl = self.doubleComma.sub(" | ",nl)
+                               nl = "| "+nl+" |\n"
+
+                       if self.newTable :
+                           nl = "| " + nl
+                           self.newTable = False
+
+               return nl
+
+
+
index 50700b2..9bdfae1 100755 (executable)
@@ -92,128 +92,7 @@ def magicMarkers(s) :
                        
 
 
-               
-## Standard Wikish (the markup of UseMod)
-       
-class WikishProcessor :
-       
-    def __init__(self,env) :
-        self.blm = re.compile("^$")
-        self.hr = re.compile("----")
-        self.h6 = re.compile("^======(.+)======")
-        self.h5 = re.compile("^=====(.+)=====")
-        self.h4 = re.compile("^====(.+)====")
-        self.h3 = re.compile("^===(.+)===")
-        self.h2 = re.compile("^==(.+)==")
-        self.h1 = re.compile("^=(.+)=")
-        self.bold = re.compile("'''(.*?)'''")
-        self.italic = re.compile("''(.*?)''")
-        
-        self.sqrbrkt = re.compile("(\[\[(\S+?)\]\])")
-        self.extlink = re.compile("(\[(http\S+)\s+(.+?)\])")
-
-               #self.wikiword = re.compile("([A-Z][a-z]+([A-Z][a-z]+)+)")
-        
-        
-        self.indent = 0        
-                 
-    def line(self,l) : 
-        nl = l.strip()
-          
-        nl = self.blm.sub("<br/><br/>",nl)
-        nl = self.hr.sub("<hr>",nl)
-        nl = self.bold.sub(r"<b>\1</b>",nl)
-        nl = self.italic.sub(r"<i>\1</i>",nl)
-
-        nl = self.h6.sub(r"<h6>\1</h6>",nl)
-        nl = self.h5.sub(r"<h5>\1</h5>",nl)
-        nl = self.h4.sub(r"<h4>\1</h4>",nl)
-        nl = self.h3.sub(r"<h3>\1</h3>",nl)
-        nl = self.h2.sub(r"<h2>\1</h2>",nl)
-        nl = self.h1.sub(r"<h1>\1</h1>",nl)
-        nl = self.sqrbrkt.sub(r"""<a href="/view/\2">\2</a>""",nl)
-        nl = self.extlink.sub(r"""<a href="\2">\3</a>""",nl)
-
-        #nl = self.wikiword.sub(r"<a href='/view/\1' title='origin'>\1</a>",nl)        
-       
-            
-        return nl
-
-
-    def outlineFilter(self,l) :
-        if l[0] != "*" :
-            if self.indent > 0 :
-                s = "</ul>"*(self.indent)
-                self.indent = 0
-                l = s + "\n" + l
-            return l
-        
-        count = 0
-        while l[count] == "*" :
-            count=count+1
-        meat = l[count:]
-
-        if count == self.indent :
-            return " " * (self.indent+1) + "<li>" + meat + "</li>"
-        if count > self.indent :
-            self.indent = self.indent + 1
-            return "<ul>\n" + " " * (self.indent+1) + "<li>" + meat + "</li>"
-        s = "</ul>" * (self.indent + 1 - count) + "<li>" + meat + "</li>" 
-        self.indent = count
-        return s
-
-    def cook(self,p) :
-        lines = (self.line(wiki_filters(l)) for l in p.split("\n"))
-        lines = (self.outlineFilter(l) for l in lines)
-        lines = (social_filters() for l in lines)        
-        return "\n".join(lines)
-
-
 null_env = Environment("",{})
-chef = WikishProcessor(null_env)
-
-class Wikish2Markdown(WikishProcessor) :
-
-       def __init__(self,convert_tables=False) :
-               WikishProcessor.__init__(self)
-               self.convert_tables = convert_tables
-                 
-       def line(self,l) :      
-               nl = l.strip()
-               nl = self.blm.sub("\n",nl)
-        
-               nl = self.bold.sub(r"**\1**",nl)
-               nl = self.italic.sub(r"*\1*",nl)
-
-               nl = self.h6.sub(r"###### \1",nl)
-               nl = self.h5.sub(r"##### \1",nl)
-               nl = self.h4.sub(r"#### \1",nl)
-               nl = self.h3.sub(r"### \1",nl)
-               nl = self.h2.sub(r"## \1",nl)
-               nl = self.h1.sub(r"# \1",nl)
-        
-               nl = self.extlink.sub(r"""[\3](\2)""",nl)
-              
-
-               if self.convert_tables :
-                       if not self.tableMode :
-                           if self.doubleComma.findall(nl) :
-                               self.tableMode = True
-                               self.newTable = True
-                       
-                       if self.tableMode :
-                           if not self.doubleComma.findall(nl) :
-                               nl = nl + "\n\n"
-                               self.tableMode = False
-                           else :
-                               nl = self.doubleComma.sub(" | ",nl)
-                               nl = "| "+nl+" |\n"
-
-                       if self.newTable :
-                           nl = "| " + nl
-                           self.newTable = False
-
-               return nl
 
 
 #### Current