Skip to content

Commit 319cf90

Browse files
committed
Strip extra divs that appear in output
1 parent 823ac86 commit 319cf90

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Unreleased Changes
99

1010
<!-- insertion marker -->
1111
- Swap out `sh` for `subprocess` module for running pandoc
12+
- Strip extra divs that appear in output
1213

1314
[0.2.0] - 2021-01-06
1415
--------------------

moin2gitwiki/moin2markdown.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,17 @@ def extract_content_section(self, html: str) -> str:
174174
if tag.has_attr("class"):
175175
del tag["class"]
176176
#
177+
# This might not always work but removing all <div>s makes output cleaner
178+
for tag in content.find_all("div"):
179+
tag.unwrap()
180+
#
177181
# now find all the images and see if they map to emojis
178182
# MoinMoin puts the emoji code in the title, so will purely match on that
179183
for tag in content.find_all("img"):
180184
if tag.has_attr("title") and tag["title"] in self.smiley_map:
181185
tag.replace_with(" " + self.smiley_map[tag["title"]] + " ")
182186

183-
return str(content)
187+
return "".join([str(x) for x in content.contents])
184188

185189
def translate(self, input: str) -> str:
186190
"""Translate HTML to Github Flavoured Markdown using pandoc"""

0 commit comments

Comments
 (0)