IIRR-34: Fix newlines around codeblocks for Redcarpet renderer#94
Open
arielj wants to merge 1 commit into
Open
IIRR-34: Fix newlines around codeblocks for Redcarpet renderer#94arielj wants to merge 1 commit into
arielj wants to merge 1 commit into
Conversation
JuanVqz
reviewed
May 29, 2026
| # fixing this at render because it's not really required by Discord | ||
| # it's just a quirk of Redcarpet | ||
| if text.match?(/[^\n]\n```(.*)\n```/m) | ||
| text = text.gsub(/[^\n]\n```(.*)\n```/m, "\n\n```\\1\n```") |
Member
There was a problem hiding this comment.
The requex you added is eathing the h of with, this worked for me:
Suggested change
| text = text.gsub(/[^\n]\n```(.*)\n```/m, "\n\n```\\1\n```") | |
| text = text.gsub(/([^\n])\n```(.*?)\n```/m, "\\1\n\n```\\2\n```") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
My previous PR #93 adding code style introduced a bug: redcarpets needs the first three-backticks of a codeblock to have 2 newlines before it to render it properly.
This is not required for the closing three-backticks and also not required by discord either.
Because of this, some of our puzzles that don't have 2 newlines before the start of a codeblock were rendered incorrectly, parsing the code that should have been part of a code block as HTML instead.
This PR fixes that by fixing the missing newline during render if needed.
I didn't add a fix in the data stored in the database because it's not really a requirement for Discord, it's just a weird thing with Redcarpet so it's fixed on the fly as needed when rendered.
I also added a bit of space after the code block because it looked too close to the next line because of how redcarpet renders
preandptags