diff --git a/app.py b/app.py
index b58af7ad67b..c6c5ac571b8 100644
--- a/app.py
+++ b/app.py
@@ -1748,18 +1748,12 @@ def get_specific_adventure(name, level, mode):
return utils.error_page(error=404, ui_message=gettext('no_such_adventure'))
adventure["content"] = safe_format(adventure.get("content", ""), **hedy_content.KEYWORDS.get(g.keyword_lang))
+ if "formatted_content" in adventure:
+ adventure['formatted_content'] = safe_format(adventure['formatted_content'],
+ **hedy_content.KEYWORDS.get(g.keyword_lang))
customizations["teachers_adventure"] = True
- current_adventure = Adventure(
- id=adventure["id"],
- author=adventure["creator"],
- short_name="level",
- name=adventure["name"],
- image=adventure.get("image", None),
- text=adventure["content"],
- is_teacher_adventure=True,
- is_command_adventure=False,
- save_name=f"{name} {level}")
+ current_adventure = Adventure.from_teacher_adventure_database_row(adventure)
adventures.append(current_adventure)
prev_level, next_level = utils.find_prev_next_levels(customizations["available_levels"], level)
diff --git a/templates/incl/adventure-tabs.html b/templates/incl/adventure-tabs.html
index bd63958378e..40d2a33efd3 100644
--- a/templates/incl/adventure-tabs.html
+++ b/templates/incl/adventure-tabs.html
@@ -43,12 +43,12 @@
>
- {{ adventure.text|commonmark }}
+ {% if adventure.is_teacher_adventure %}{{ adventure.text|safe }}{% else %}{{ adventure.text|commonmark }}{% endif %}
{% if adventure.example_code %}
- {{ adventure.example_code|commonmark }}
+ {% if adventure.is_teacher_adventure %}{{ adventure.example_code|safe }}{% else %}{{ adventure.example_code|commonmark }}{% endif %}
{% endif %}
{% if public_adventures_page %}
diff --git a/website/frontend_types.py b/website/frontend_types.py
index 071f77470e7..a725d2dca50 100644
--- a/website/frontend_types.py
+++ b/website/frontend_types.py
@@ -108,10 +108,17 @@ def halve_adventure_content(content, max_char_length=750):
example_code = ""
if len(text_without_tags) > max_char_length:
# Split text at a suitable breaking point
- split_index = content.find('', len(text_without_tags)//2) # Find a closing paragraph tag.
+ split_index = -1
+ chosen_tag = None
+ for t in ["pre", "p"]:
+ split_index = content.find(f'{t}>', len(text_without_tags)//2) # Find a closing paragraph tag.
+ if split_index:
+ chosen_tag = t
+ break
if split_index > -1:
- text = content[:split_index]
- example_code = content[split_index:]
+ # since we find the first occurence of , we append: / + > + 1 (to start from next char) = 3
+ text = content[:split_index + len(chosen_tag) + 3]
+ example_code = content[split_index + len(chosen_tag) + 3:]
else:
# If no suitable split point found, don't truncate content
text = content