Repository navigation
Emoji in code block, fix issue #329 - #335
Conversation
| const withColons = `:${k}:`; | ||
| const asEmoji = emojis[k]; | ||
| content = content.replace(new RegExp(withColons, "g"), asEmoji); | ||
| const contentList = content.split("```"); |
There was a problem hiding this comment.
This is a good start but I think it might be a bit too simple? I'd probably go for something like this:
- Split the content into a list of lines
- Loop through lines and keep a
isInCodeBlockboolean - Whenever we encounter a line containing "```" we flip the boolean
- For each line when
isInCodeBlockis true, do the emoji replacement - Join the lines back together
There was a problem hiding this comment.
Got it—just wondering, why wouldn't we want to do the first change?
There was a problem hiding this comment.
@jollypolly123 based on my reading of the spec I think the triple backticks have to be the start of a line or preceded only by whitespace on the line in order to fence off a code block. So it is possible (although unlikely) that you could have a "```" in the middle of content. Therefore just splitting on that character group is not enough.
Simple:
Hello
Triple backticks at end of line:
Hello```
Indented
Ok
There was a problem hiding this comment.
Gotcha thanks!
samtstern
left a comment
There was a problem hiding this comment.
Just one more change, thanks!
Co-authored-by: Sam Stern <samstern@google.com>
|
@jollypolly123 thank you! This should be fixed the next time @techtrailhead deploys the site. |
No description provided.