save(docs_text, code_text)
return sections
-def preprocess(comment):
+def preprocess(comment, section_nr):
# Add cross-references before having the text processed by markdown.
-# It's possible to reference another file, like this : [[file]] or a specific function of
+# It's possible to reference another file, like this : [[pycco.py]] or a specific function of
# another file, like this: [[file#func]]
def repl(match):
- return "[%s](%s)" % (match.group(1), destination(match.group(1)))
+ return "[%s](%s)" % (match.group(1), path.basename(destination(match.group(1))))
+
+ def repl2(match):
+ return "[%s](%s)" % (match.group(1), destination(match.group(1)) + "#section-" + str(section_nr))
+
return re.sub('\[\[(.+)\]\]', repl, comment)
fragments = re.split(language["divider_html"], output)
for i, section in enumerate(sections):
section["code_html"] = highlight_start + shift(fragments, "") + highlight_end
- section["docs_html"] = markdown(preprocess(section["docs_text"]))
+ section["docs_html"] = markdown(preprocess(section["docs_text"], i))
section["num"] = i
# Once all of the code is finished highlighting, we can generate the HTML file
# the name of the Pygments lexer and the symbol that indicates a comment. To
# add another language to Pycco's repertoire, add it here.
languages = {
- ".coffee": { "name": "coffee-script", "symbol": "#" },
+# ".coffee": { "name": "coffee-script", "symbol": "#" },
".js": { "name": "javascript", "symbol": "//" },
".rb": { "name": "ruby", "symbol": "#" },
".py": { "name": "python", "symbol": "#" },