Skip to content

Commit 677b52b

Browse files
authored
Merge pull request #35 from Xpirix/fix_notable_fixes_markdown
Fix markown rendering for changelog
2 parents 681bd3b + d3d4280 commit 677b52b

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

django_project/base/templatetags/custom_markup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ def base_markdown(value):
2323
extensions=extensions,
2424
safe_mode=True,
2525
enable_attributes=False)
26-
html_output = html_output.replace(
27-
'<table>', '<table class="table table-striped table-bordered"')
26+
# html_output = html_output.replace(
27+
# '<table>', '<p><table>').replace(
28+
# '</table>', '</table></p>')
2829
return mark_safe(html_output)
2930

3031

django_project/changes/templates/entry/includes/entry_detail.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ <h3><span>Feature:</span> {{ entry.title }}</h3>
5353
word-wrap: normal;
5454
}
5555
</style>
56-
<div class="column is-8">
56+
<div class="column">
5757
{{ entry.description|base_markdown }}
5858
</div>
59+
{% if entry.image_file %}
5960
<div class="column is-4 has-text-centered">
60-
{% if entry.image_file %}
6161
{% if entry.image_file|is_gif %}
6262
{% if not rst_download %}
6363
<img id="{{ entry.image_file.url }}" class="image"
@@ -81,8 +81,8 @@ <h3><span>Feature:</span> {{ entry.title }}</h3>
8181
alt=""/>
8282
</a>
8383
{% endif %}
84-
{% endif %}
85-
</div>
84+
</div>
85+
{% endif %}
8686
</div>
8787

8888
{% if entry.video %}

django_project/changes/views/version.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,11 +693,10 @@ def render_to_response(self, context, **response_kwargs):
693693
context=context,
694694
**response_kwargs
695695
)
696-
697696
# convert the html to markdown
698697
converted_doc = pypandoc.convert_text(
699698
document.rendered_content.encode('utf8', 'ignore'),
700-
'md', format='html', extra_args=['--wrap=none'])
699+
'gfm', format='html')
701700
converted_doc = converted_doc.replace('/media/images/', 'images/')
702701

703702
# prepare the ZIP file
@@ -766,10 +765,13 @@ def _prepare_zip_archive(self, document, version_obj):
766765
document = self._convert_headers(document)
767766
# Remove CSS styles and classes
768767
document = re.sub(r'\{.*?\}', '', document)
769-
# Regular expression pattern for Markdown image syntax
770-
pattern = re.compile(r'!\[.*?\]\((.*?)\)')
771-
# Find all matches
772-
images = pattern.findall(document)
768+
# Use BeautifulSoup to extract image sources from HTML <img> tags
769+
images = []
770+
soup = BeautifulSoup(document, 'html.parser')
771+
for img_tag in soup.find_all('img'):
772+
src = img_tag.get('src')
773+
if src and src.startswith('images/'):
774+
images.append(src)
773775
if not images:
774776
images = []
775777

0 commit comments

Comments
 (0)