output = output.replace(highlight_start, "").replace(highlight_end, "")
fragments = re.split(language["divider_html"], output)
for i, section in enumerate(sections):
- section["code_html"] = highlight_start + fragments[i] + highlight_end
+ section["code_html"] = highlight_start + shift(fragments, "") + highlight_end
section["docs_html"] = markdown(section["docs_text"])
section["num"] = i
# The mirror of `divider_text` that we expect Pygments to return. We can split
# on this to recover the original sections.
- l["divider_html"] = re.compile(r'\n*<span class="c">' + l["symbol"] + 'DIVIDER</span>\n*')
+ l["divider_html"] = re.compile(r'\n*<span class="c[1]?">' + l["symbol"] + 'DIVIDER</span>\n*')
# Get the Pygments Lexer for this language.
l["lexer"] = lexers.get_lexer_by_name(l["name"])
name = filepath.replace(filepath[ filepath.rindex("."): ], "")
return "docs/" + path.basename(name) + ".html"
+# Shift items off the front of the `list` until it is empty, then return
+# `default`.
+def shift(list, default):
+ try:
+ return list.pop(0)
+ except IndexError:
+ return default
+
# Ensure that the destination directory exists.
def ensure_directory():
Popen(["mkdir", "-p", "docs"]).wait()