Skip to content

Commit

Permalink
Fix invalid usage of re.sub in wiki converter
Browse files Browse the repository at this point in the history
The flags parameter was being passed in as the count parameter, so not all
links got converted properly (and probably caused some other issues as well).

Removed the flags parameter, since it was clearly not doing anything and
it's not even valid when used with a precompiled pattern.

Perhaps the compiled patterns need to be updated to include these flags? Will
add them later if it turns out to be needed.
  • Loading branch information
Davíð Steinn Geirsson committed Jun 30, 2020
1 parent c988fbd commit 05b77cc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions redmine_gitlab_migrator/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ def convert(self, text):
# is not handled. So let's fix that.

# [[ wikipage | link_text ]] -> [link_text](wikipage)
text = re.sub(self.regexWikiLinkWithText, self.wiki_link, text, re.MULTILINE | re.DOTALL)
text = re.sub(self.regexWikiLinkWithText, self.wiki_link, text)

# [[ link_url ]] -> [link_url](link_url)
text = re.sub(self.regexWikiLinkWithoutText, self.wiki_link, text, re.MULTILINE | re.DOTALL)
text = re.sub(self.regexWikiLinkWithoutText, self.wiki_link, text)

# nested lists, fix at least the common issues
text = text.replace(" \\#\\*", " -")
Expand All @@ -87,16 +87,16 @@ def convert(self, text):
text = text.replace("> ", ">")

# wiki note macros
text = re.sub(self.regexTipMacro, r'---\n**TIP**: \1\n---\n', text, re.MULTILINE | re.DOTALL)
text = re.sub(self.regexNoteMacro, r'---\n**NOTE**: \1\n---\n', text, re.MULTILINE | re.DOTALL)
text = re.sub(self.regexWarningMacro, r'---\n**WARNING**: \1\n---\n', text, re.MULTILINE | re.DOTALL)
text = re.sub(self.regexImportantMacro, r'---\n**IMPORTANT**: \1\n---\n', text, re.MULTILINE | re.DOTALL)
text = re.sub(self.regexTipMacro, r'---\n**TIP**: \1\n---\n', text)
text = re.sub(self.regexNoteMacro, r'---\n**NOTE**: \1\n---\n', text)
text = re.sub(self.regexWarningMacro, r'---\n**WARNING**: \1\n---\n', text)
text = re.sub(self.regexImportantMacro, r'---\n**IMPORTANT**: \1\n---\n', text)

# all other macros
text = re.sub(self.regexAnyMacro, r'\1', text, re.MULTILINE | re.DOTALL)
text = re.sub(self.regexAnyMacro, r'\1', text)

# attachments in notes
text = re.sub(self.regexAttachment, r"\n\n*(Merged from Redmine, please check first note for attachment named **\1**)*", text, re.MULTILINE | re.DOTALL)
text = re.sub(self.regexAttachment, r"\n\n*(Merged from Redmine, please check first note for attachment named **\1**)*", text)

# code highlight
codeHighlights = re.findall(self.regexCodeHighlight, text)
Expand Down

0 comments on commit 05b77cc

Please sign in to comment.