Skip to content

Commit

Permalink
Fixed square brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
heraldofsolace committed Jun 1, 2024
1 parent 03110c8 commit 78d3205
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def create_link_for_tag(self, tag, possible_matches, subreddit="vim"):
request = requests.head(link)

if request.ok:
topic = topic.replace("[", "\uff3b").replace("]", "\uff3d")
text += "* [`{}`]({}) in _{}.txt_\n".format(topic, link, doc)
return text

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
praw==7.0.0
prawcore==1.3.0
pytest
11 changes: 10 additions & 1 deletion test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_double_backtick_comment(self):

bot = Bot()
tags = [":tab", ":options", ":tjump", "c_CTRL-R_CTRL-W",
":execute", "expand()", "`["]
":execute", "expand()"]

text = "Test comment: " + \
','.join(list(map(lambda t: "``:h {}``".format(t), tags)))
Expand Down Expand Up @@ -192,5 +192,14 @@ def test_neovim_index(self):
reply = bot.create_comment(":h index", None, "neovim")
self.assertIn("https://neovim.io/doc/user/vimindex.html", reply)

def test_square_brackets(self):
"""
Test that square brackets are handled correctly
"""

bot = Bot()
reply = bot.create_comment("`:h ]p`", None, "vim")
self.assertIn("]", reply)

if __name__ == "__main__":
unittest.main()

0 comments on commit 78d3205

Please sign in to comment.