Commits

Yang Zhang  committed 1a4bc75

some problem

  • Participants
  • Parent commits fa37dc8

Comments (0)

Files changed (1)

File parser/parser.py

 
 _strong = re.compile(r'\*(?P<strong>.+)\*', re.M)
 
-_auto_link = re.compile(r'(?P<link>(http|https)://.+[\b|\s]?)')
+_auto_link = re.compile(r'(?P<link>(http|https)://.+[\b|\s]?)', re.M)
+
+
+
+'''a=
+something here:
+1. test1
+2. nice2
+3.  whatever :
+    1. whats
+    2. is 
+    3. this
+'''
+_order_lists = re.compile(r':\n([\d\s]+\..+\n?)+',re.M)
+_list_items = re.compile(r'[\d\s]+\. (?P<item>.*)',re.M)
 
 def parse_head(content):
     if _header1.match(content)!=None:
 def auto_link(content):
     return re.sub(_auto_link,r'<a href="\g<link>">\g<link></a>',content)
 
+def parse_list_item(item):
+    return re.sub(_list_items,r'<li>\g<item></li>',item)
+
+def parse_ordered_list(content):
+    result = _order_lists.search(content)
+    print "the content is", content
+    print "the result is", result
+    if result is None:
+        return content
+    result_content = '<ol>'
+    while(result and type(result)!=type('')):
+        temp_content = result.group(0)
+        result_content += parse_list_item(temp_content)
+        result = parse_ordered_list(content[result.start(1):])
+    result_content += "</ol>"
+    return result_content
+
+
+
+
+
+
+
+
+
+
+
+