mirror of
https://github.com/xoofx/markdig.git
synced 2026-11-16 17:30:52 +00:00
Add test precise position for emojis
This commit is contained in:
@@ -360,6 +360,17 @@ literal ( 2, 5) 17-20
|
||||
", "definitionlists");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmoji()
|
||||
{
|
||||
// 01 2345
|
||||
Check("0\n :)\n", @"
|
||||
paragraph ( 0, 0) 0-4
|
||||
literal ( 0, 0) 0-0
|
||||
linebreak ( 0, 1) 1-1
|
||||
emoji ( 1, 1) 3-4
|
||||
", "emojis");
|
||||
}
|
||||
|
||||
private static void Check(string text, string expectedResult, string extensions = null)
|
||||
{
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace Markdig.Extensions.Emoji
|
||||
public override bool Match(InlineProcessor processor, ref StringSlice slice)
|
||||
{
|
||||
string match;
|
||||
var startPosition = slice.Start;
|
||||
if (!textMatchHelper.TryMatch(slice.Text, slice.Start, slice.Length, out match))
|
||||
{
|
||||
return false;
|
||||
@@ -89,7 +90,16 @@ namespace Markdig.Extensions.Emoji
|
||||
slice.Start += match.Length;
|
||||
|
||||
// Push the EmojiInline
|
||||
processor.Inline = new EmojiInline(unicode) {Match = match};
|
||||
int line;
|
||||
int column;
|
||||
processor.Inline = new EmojiInline(unicode)
|
||||
{
|
||||
SourceStartPosition = processor.GetSourcePosition(startPosition, out line, out column),
|
||||
Line = line,
|
||||
Column = column,
|
||||
Match = match
|
||||
};
|
||||
processor.Inline.SourceEndPosition = processor.Inline.SourceStartPosition + match.Length - 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user