From d646b237193d244535d6336776e3d8f46641136f Mon Sep 17 00:00:00 2001 From: Jose De Freitas Date: Sun, 21 Feb 2021 14:12:25 -0500 Subject: [PATCH] Add commas rule --- linter/rules/featured_playlists.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/linter/rules/featured_playlists.py b/linter/rules/featured_playlists.py index 49545ae..2670ee1 100644 --- a/linter/rules/featured_playlists.py +++ b/linter/rules/featured_playlists.py @@ -23,18 +23,40 @@ def featured_playlists(): for line, value in enumerate(content_readme): if checker in value: + + words = value[len(checker)+1:-4] # Check for trailing slash if len(value) < length and value[-2] != '\\': if value[-2] == ' ': - content_readme[line] = value[:-1] + '\\' + '\n' + '
' + '\n' + content_readme[line] = value[:-1] + '\\' + '\n
\n' with open(file_readme, 'w') as write_readme: write_readme.writelines(content_readme) else: - content_readme[line] = value[:-1] + ' \\' + '\n' + '
' + '\n' + content_readme[line] = value[:-1] + ' \\' + '\n
\n' with open(file_readme, 'w') as write_readme: write_readme.writelines(content_readme) result = "Trailing slash wasn't found.\nFixed." + # Check for well-formatted backsticks + if value.count('`') % 2 != 0: + content = words.split(', ') + fix_words = [] + + for topic in content: + if topic[0] != '`' and topic[-1] != '`': + fix_words.append('`' + topic + '`') + elif topic[-1] != '`': + fix_words.append(topic + '`') + elif topic[0] != '`': + fix_words.append('`' + topic) + else: + fix_words.append(topic) + + content_readme[line] = value[:len(checker)] + ' ' + ', '.join(fix_words) + '. \\\n' + with open(file_readme, 'w') as write_readme: + write_readme.writelines(content_readme) + + result = "Backsticks weren't found.\nFixed." return result