Commit 8c92c3f8 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Fix headers bug

parent 5a472292
......@@ -283,3 +283,12 @@ class Functions:
def query_fasta_file_exists(res_dir):
fasta_file = os.path.join(res_dir, ".query")
return os.path.exists(fasta_file) and os.path.isfile(fasta_file)
@staticmethod
def replace_headers(text):
headers = re.findall("<h\d id=\"[^\"]+\">", text)
for header in headers:
id_header = re.search("id=\"([^\"]+)\"", header).group(1)
text = text.replace(header, "<span class=\"anchor\" id=\"%s\"></span>%s" %
(id_header, re.sub(r"id=\"[^\"]+\"", "class=\"section\"", header)))
return text
......@@ -49,7 +49,7 @@ Files must be in fasta format. We recommend using gzipped files to preserve band
Allowed extensions: fa, fasta, fna, fa.gz, fasta.gz, fna.gz
Max file size: ###size### (###size_unc### once uncompressed, ###size_ava### in all-vs-all mode)
Max file size: {{size}} ({{size_unc}} once uncompressed, {{size_ava}} in all-vs-all mode)
{% set puce=puce+1 %}
......@@ -59,7 +59,7 @@ Optional field
Works like the target fasta. If not given, target file will be mapped to itself, in all-vs-all mode.
Max file size: ###size### (###size_unc### once uncompressed)
Max file size: {{size}} ({{size_unc}} once uncompressed)
{% set puce=puce+1 %}
......
......@@ -4,6 +4,13 @@ body {
padding-top: 50px;
}
.anchor{
display: block;
height: 50px; /*same height as header*/
margin-top: -50px; /*same height as header*/
visibility: hidden;
}
#main-error {
display: none;
width: 100%;
......
This diff is collapsed.
......@@ -63,7 +63,7 @@
{% endif %}
<div id="body">
{{ content }}
{{ content | safe }}
</div>
{% endblock %}
\ No newline at end of file
......@@ -325,12 +325,6 @@ def get_file(file, gzip=False): # pragma: no cover
def documentation_run():
latest = Latest()
version = latest.latest
with open(os.path.join(app_folder, "md", "doc_run.md"), "r", encoding='utf-8') as install_instr:
content = install_instr.read()
env = Environment()
template = env.from_string(content)
content = template.render(mode=MODE, version=version)
md = Markdown(extensions=[TocExtension(baselevel=1)])
max_upload_file_size = config_reader.max_upload_file_size
if max_upload_file_size == -1:
max_upload_file_size = "no limit"
......@@ -346,9 +340,14 @@ def documentation_run():
max_upload_size_ava = "no limit"
else:
max_upload_size_ava = Functions.get_readable_size(max_upload_size_ava, 0)
content = Markup(md.convert(content)).replace("###size###", max_upload_file_size)\
.replace("###size_unc###", max_upload_size)\
.replace("###size_ava###", max_upload_size_ava)
with open(os.path.join(app_folder, "md", "doc_run.md"), "r", encoding='utf-8') as install_instr:
content = install_instr.read()
env = Environment()
template = env.from_string(content)
content = template.render(mode=MODE, version=version, size=max_upload_file_size, size_unc=max_upload_size,
size_ava=max_upload_size_ava)
md = Markdown(extensions=[TocExtension(baselevel=1)])
content = Functions.replace_headers(str(Markup(md.convert(content))))
toc = Markup(md.toc)
return render_template("documentation.html", menu="documentation", content=content, toc=toc)
......@@ -359,7 +358,7 @@ def documentation_result():
encoding='utf-8') as install_instr:
content = install_instr.read()
md = Markdown(extensions=[TocExtension(baselevel=1)])
content = Markup(md.convert(content))
content = Functions.replace_headers(str(Markup(md.convert(content))))
toc = Markup(md.toc)
return render_template("documentation.html", menu="documentation", content=content, toc=toc)
......@@ -370,7 +369,7 @@ def documentation_formats():
encoding='utf-8') as install_instr:
content = install_instr.read()
md = Markdown(extensions=[TocExtension(baselevel=1), TableExtension()])
content = Markup(md.convert(content))
content = Functions.replace_headers(str(Markup(md.convert(content))))
toc = Markup(md.toc)
return render_template("documentation.html", menu="documentation", content=content, toc=toc)
......@@ -381,7 +380,7 @@ def documentation_dotplot():
encoding='utf-8') as install_instr:
content = install_instr.read()
md = Markdown(extensions=[TocExtension(baselevel=1)])
content = Markup(md.convert(content))
content = Functions.replace_headers(str(Markup(md.convert(content))))
toc = Markup(md.toc)
return render_template("documentation.html", menu="documentation", content=content, toc=toc)
......@@ -396,7 +395,7 @@ def install():
template = env.from_string(content)
content = template.render(version=latest.latest, win32=latest.win32)
md = Markdown(extensions=[TocExtension(baselevel=1)])
content = Markup(md.convert(content))
content = Functions.replace_headers(str(Markup(md.convert(content))))
toc = Markup(md.toc)
return render_template("documentation.html", menu="install", content=content, toc=toc)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment