Skip to content
This repository has been archived by the owner on Jan 27, 2019. It is now read-only.

Commit

Permalink
Small changes i guess?
Browse files Browse the repository at this point in the history
  • Loading branch information
tomleo committed Nov 21, 2011
1 parent a7100c3 commit 9f12c4d
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions parse.py
Expand Up @@ -156,28 +156,41 @@ def get_html(self, style_='colorful'):


html=highlight(self.code_, lex, htmlFormat) html=highlight(self.code_, lex, htmlFormat)


self.code_=self.code_.split('\n') #self.code_=self.code_.split('\n')

#assert(len(self.code_)==len(self.comments_))
assert(len(self.code_)==len(self.comments_)) #print("About to enter the get_html() function forloop")
print("About to enter the get_html() function forloop") #for i, line in enumerate(self.code_):
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]: if self.comments_[i]:
#tmp=list(html.partition(self.code_[i])) pattern = re.compile('<pre>(.*?)</pre>', re.I | re.S)
tmp=list(html.partition('<pre>')) temp=pattern.split(line)
print("1. ", tmp) temp.insert(1, '<a href="#" title={0}">'.format(self.comment_[i]))

temp.insert(4, '</a>')
before='<a href="#" title="{0}">'.format(self.comments_[i])
tmp.insert(2, before)


print("2. ", tmp) html.join('\n')


after='</a>'
tmp.insert(3, after) #for i, each in enumerate(pattern.split(html)):

# print(i, " ", each)
html=''.join(tmp)
print("3. ", tmp)
return html return html





class parseNotes(object): class parseNotes(object):
def __init__(self, file_, *args, **kargs): def __init__(self, file_, *args, **kargs):
Expand Down Expand Up @@ -254,12 +267,13 @@ def format_html(self, bun, meat):
#style_=HtmlFormatter(style='colorful').style #style_=HtmlFormatter(style='colorful').style
#format_=HtmlFormatter(style=style_) #format_=HtmlFormatter(style=style_)
c=Code(lang, code).get_html() c=Code(lang, code).get_html()
print(c) #print(c)
exit() exit()
return c return c
else: else:
pass pass
#print ('bun value was: ', bun) #print ('bun value was: ', bun)



if __name__ == '__main__': if __name__ == '__main__':
test = parseNotes('sample.n') test = parseNotes('sample.n')

0 comments on commit 9f12c4d

Please sign in to comment.