"""
"""
def __init__(self):
- self.input_iter = None
- self.index_past = {}
- self.index = {}
+ self._input_iter = None
+ self._index_past = {}
+ self._index = {}
def index_add(self, key, val):
"""
@param val:
@key val:
"""
- self.index[key] = val
+ self._index[key] = val
+
+ def index(self, key):
+ """
+ Get index
+ """
+ return self._index[key]
def markup(self, input_iter):
"""
# dlist = ["*"]
# tag_filter = HTMLTagFilter.HTMLTagFilter(HTMLTagFilter.DENY_ALLOW, alist, dlist)
+ self.index_add("figs", [])
+
anchor = ""
for line in self.input_iter:
line = self._default_markup_rule(line)
# load index
try:
index_file = open(path_to_index, "r")
- self.index_past = pickle.load(index_file)
+ self._index_past = pickle.load(index_file)
index_file.close()
except IOError:
sys.stderr.write("warn: cannot read index file,\n")
# save index
try:
index_file = open(path_to_index, "w")
- pickle.dump(self.index, index_file)
+ pickle.dump(self._index, index_file)
index_file.close()
except IOError:
sys.stderr.write("warn: cannot write index file,\n")
print self._fig_start()
line = self.input_iter.next()
+ imgname = ""
+ imgname_s = ""
hash = ""
hash_s = ""
match_o1 = re.search(ur"<([^,]*?)>", line)
match_o2 = re.search(ur"<(.*?),\s*(.*?)>", line)
if not match_o1 == None:
+ imgname = match_o1.group(1)
imgname_s = re.sub(r"(.[A-Za-z0-9_]+)$", r"_s\1", match_o1.group(1))
- hash = self.hashlist.get(match_o1.group(1), "")
- hash_s = self.hashlist.get(imgname_s, "")
- if hash_s == "":
- hash_s = self.hashlist.get(match_o1.group(1), "")
elif not match_o2 == None:
- hash = self.hashlist.get(match_o2.group(1), "")
- hash_s = self.hashlist.get(match_o2.group(2), "")
+ imgname = match_o1.group(1)
+ imgname_s = match_o1.group(2)
+
+
+ hash = self.hashlist.get(imgname, "")
+ hash_s = self.hashlist.get(imgname_s, "")
+ if hash_s == "":
+ hash_s = hash
print """<a href="/blob.pl?id=%s">
<slash type="image" id="%s" title="%s">
</a>
""" % (hash, hash_s, str_title)
+
+ dic = self.index("figs")
+ dic.append(imgname)
+ if imgname_s != "":
+ dic.append(imgname_s)
+
print self._fig_end(str_title);
str_title = re.search(ur"^☆(表.*)$", line).group(1)
except AttributeError:
str_title = ""
- print _self.table_start(str_title)
+ print self._table_start(str_title)
num_row = 0
table_contents = []
line = line.strip(" \n")
if re.search(ur"^\s*$", line):
break
- line = default_markup_rule(line)
+ line = self._default_markup_rule(line)
if re.search(ur"^〓", line):
line = re.sub(ur"^〓", "", line)
tag_mode = "th"