Browse files

Small changes i guess?

  • Loading branch information...
1 parent a7100c3 commit 9f12c4d1e1aba0637ca8f3438708178bb2fd6a2a @tomleo committed Nov 21, 2011
Showing with 33 additions and 19 deletions.
  1. +33 −19 parse.py
View
52 parse.py
@@ -156,28 +156,41 @@ def get_html(self, style_='colorful'):
html=highlight(self.code_, lex, htmlFormat)
- self.code_=self.code_.split('\n')
-
- assert(len(self.code_)==len(self.comments_))
- print("About to enter the get_html() function forloop")
- for i, line in enumerate(self.code_):
+ #self.code_=self.code_.split('\n')
+ #assert(len(self.code_)==len(self.comments_))
+ #print("About to enter the get_html() function forloop")
+ #for i, line in enumerate(self.code_):
+ # if self.comments_[i]:
+ # #tmp=list(html.partition(self.code_[i]))
+ # tmp=list(html.partition('<pre>'))
+ # print("1. ", tmp)
+ # before='<a href="#" title="{0}">'.format(self.comments_[i])
+ # tmp.insert(2, before)
+ # print("2. ", tmp)
+ # after='</a>'
+ # tmp.insert(3, after)
+ # html=''.join(tmp)
+ # print("3. ", tmp)
+
+ # re.I = ignore case
+ # re.S = dotall
+ html=html.split('\n')
+ for i, line in enumerate(html[:]):
if self.comments_[i]:
- #tmp=list(html.partition(self.code_[i]))
- tmp=list(html.partition('<pre>'))
- print("1. ", tmp)
-
- before='<a href="#" title="{0}">'.format(self.comments_[i])
- tmp.insert(2, before)
+ pattern = re.compile('<pre>(.*?)</pre>', re.I | re.S)
+ temp=pattern.split(line)
+ temp.insert(1, '<a href="#" title={0}">'.format(self.comment_[i]))
+ temp.insert(4, '</a>')
- print("2. ", tmp)
+ html.join('\n')
- after='</a>'
- tmp.insert(3, after)
-
- html=''.join(tmp)
- print("3. ", tmp)
+
+ #for i, each in enumerate(pattern.split(html)):
+ # print(i, " ", each)
+
return html
-
+
+
class parseNotes(object):
def __init__(self, file_, *args, **kargs):
@@ -254,12 +267,13 @@ def format_html(self, bun, meat):
#style_=HtmlFormatter(style='colorful').style
#format_=HtmlFormatter(style=style_)
c=Code(lang, code).get_html()
- print(c)
+ #print(c)
exit()
return c
else:
pass
#print ('bun value was: ', bun)
+
if __name__ == '__main__':
test = parseNotes('sample.n')

0 comments on commit 9f12c4d

Please sign in to comment.