Skip to content

Commit

Permalink
show HTML in media description (with galleria), fix #521
Browse files Browse the repository at this point in the history
  • Loading branch information
saimn committed Jul 8, 2024
1 parent cf15fcc commit c467193
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sigal/themes/galleria/templates/album_items.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{% macro img_description(media) -%}
{%- if media.big -%}<a href='{{ media.big_url }}'>Full size</a>{%- endif -%}
{# clean up tags and whitespace, including newlines, in the description #}
{%- if media.description -%}<br>{{ media.description | striptags }}{%- endif -%}
{%- if media.description -%}<br>{{ media.description }}{%- endif -%}
{%- if media.exif -%}
<div class='film-meta'>
{%- if media.exif.iso -%}<abbr title='film speed'>{{ media.exif.iso }}</abbr> {%- endif -%}
Expand Down
5 changes: 4 additions & 1 deletion src/sigal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ def read_markdown(filename):
# will be available, this can be removed.
MD.Meta = {}

html = MD.convert(text)
# remove remaining linebreaks
html = "".join(html.splitlines())
# Mark HTML with Markup to prevent jinja2 autoescaping
output = {"description": Markup(MD.convert(text))}
output = {"description": Markup(html)}

try:
meta = MD.Meta.copy()
Expand Down
8 changes: 7 additions & 1 deletion tests/sample/pictures/dir1/test1/11.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Title: Foo Bar
Location: Bavaria

This is a funny description of this image
This is a *funny* **description** of this image

With a nice list

* item 1
* item 2
* item 3

0 comments on commit c467193

Please sign in to comment.