Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Markdig.Tests/TestCustomEmojis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,20 @@ public void TestCustomEmojiValidation()
smileyToEmoji.Add("a", "c"); // "a" already exists in emojiToUnicode
Assert.Throws<ArgumentException>(() => new EmojiMapping(emojiToUnicode, smileyToEmoji));
}

[Test]
[TestCase("|test|\n|-|\n|:x:|", "<table>\n<thead>\n<tr>\n<th>test</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>❌</td>\n</tr>\n</tbody>\n</table>\n")]
[TestCase("|test|\n|-|\n| :x: |", "<table>\n<thead>\n<tr>\n<th>test</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>❌</td>\n</tr>\n</tbody>\n</table>\n")]
[TestCase("|test|\n|-|\n|1:x:|", "<table>\n<thead>\n<tr>\n<th>test</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>1:x:</td>\n</tr>\n</tbody>\n</table>\n")]
[TestCase("|test|\n|-|\n|w:x:y|", "<table>\n<thead>\n<tr>\n<th>test</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>w:x:y</td>\n</tr>\n</tbody>\n</table>\n")]
public void TestEmojiInPipeTable(string input, string expected)
{
var pipeline = new MarkdownPipelineBuilder()
.UseEmojiAndSmiley()
.UsePipeTables()
.Build();

var actual = Markdown.ToHtml(input, pipeline);
Assert.AreEqual(expected, actual);
}
}
5 changes: 3 additions & 2 deletions src/Markdig/Extensions/Emoji/EmojiParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public EmojiParser(EmojiMapping emojiMapping)
/// </summary>
public override bool Match(InlineProcessor processor, ref StringSlice slice)
{
// Previous char must be a space
if (!slice.PeekCharExtra(-1).IsWhiteSpaceOrZero())
// Previous char must be a space or non-alphanumeric.
var prevChar = slice.PeekCharExtra(-1);
if (!prevChar.IsWhiteSpaceOrZero() && char.IsLetterOrDigit(prevChar))
Comment thread
prozolic marked this conversation as resolved.
Outdated
{
Comment thread
prozolic marked this conversation as resolved.
return false;
}
Expand Down
Loading