Closed calebeda closed 5 years ago
Nice fix @calebeda. This definitely fixes the issue with the original array representation being posted to Reddit.
I changed the title of the corresponding issue to be more accurate. The problem was that the original string did not follow the Markdown syntax. The square brackets, extraneous commas, and new line characters were a part of Python's representation of strings. What we are doing here is converting that string into valid Markdown.
Good work with what has been done so far. However, I feel that we could do a bit more to make the formatting even nicer. Here are some suggestions:
Notice that when the bot posts, the single \n
is ignored? This is because in Markdown, to begin a new paragraph, two newlines have to be in a row. Maybe search and replace any single \n
with two \n
s? (Have to be careful to not add extra new lines when there are already two or more \n
s in a row.
Add a heading before each image transcription. Each item in the original array represents one image transcription. Currently, if the function is used to format multiple transcriptions, it looks like they are all a part of one image. Instead, we can insert some text that uses Markdown syntax to organize the content of the post better.
Escape characters that should not be considered part of Markdown syntax. Currently, I believe that if a image that is transcribed contains a character used in Markdown (for example: #
, ``,
*`, etc) it will be considered a part of the syntax rather than the message content. If one of these characters is found in the string, the function should escape it using an escape character,
These are just suggestions, and not all three have to be addressed right away. If they are not addressed then they can be opened as separate issues.
Looks good to me, and I think Andrew brings up some good points. For the purposes of this PR I would approve the code currently in this PR however if you decide to add any of Andrew's suggestions I will hold off.
I added a new function with commit b77df85c that addresses the new line issue. It adds a second '\n' to single new line calls and it ignores double new line calls that had already existed before the function call.
The cause for the bot posting replies that still contained markdown syntax was that the bot was posting/replying with an array that stored the transcribed text. The quick fix for this was to create a function that creates an empty string variable then concatenates each element in order from the array to the string variable and then finally returns the string variable. The function was then implemented where ever the TranscribeImages() function was called.