diff --git a/src/Markdig.Tests/TestEmphasisPlus.cs b/src/Markdig.Tests/TestEmphasisPlus.cs index 9c2fdc776..fda75236b 100644 --- a/src/Markdig.Tests/TestEmphasisPlus.cs +++ b/src/Markdig.Tests/TestEmphasisPlus.cs @@ -1,7 +1,10 @@ // Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. +// This file is licensed under the BSD-Clause 2 license. // See the license.txt file in the project root for more information. +using Markdig.Syntax; +using Markdig.Syntax.Inlines; + namespace Markdig.Tests; [TestFixture] @@ -18,4 +21,17 @@ public void NormalStrongNormal() { TestParser.TestSpec("normal ***Strong emphasis*** normal", "
normal Strong emphasis normal
", ""); } + + [Test] + public void OpenEmphasisHasConvenientContentStringSlice() + { + var pipeline = new MarkdownPipelineBuilder().Build(); + + var document = Markdown.Parse("test*test", pipeline); + + var emphasisDelimiterLiteral = (LiteralInline)((ParagraphBlock)document.LastChild).Inline.ElementAt(1); + Assert.That(emphasisDelimiterLiteral.Content.Text == "test*test"); + Assert.That(emphasisDelimiterLiteral.Content.Start == 4); + Assert.That(emphasisDelimiterLiteral.Content.End == 4); + } } \ No newline at end of file diff --git a/src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs b/src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs index 11915dba7..599aca3b3 100644 --- a/src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs +++ b/src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs @@ -1,5 +1,5 @@ // Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. +// This file is licensed under the BSD-Clause 2 license. // See the license.txt file in the project root for more information. using System.Diagnostics; @@ -109,7 +109,7 @@ public bool PostProcess(InlineProcessor state, Inline? root, Inline? lastChild, var child = container.FirstChild; while (child != null) { - // Stop the search on the delimitation child + // Stop the search on the delimitation child if (child == lastChild) { break; @@ -197,7 +197,7 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice) if (canOpen) delimiterType |= DelimiterType.Open; if (canClose) delimiterType |= DelimiterType.Close; - var delimiter = new EmphasisDelimiterInline(this, emphasisDesc) + var delimiter = new EmphasisDelimiterInline(this, emphasisDesc, new StringSlice(slice.Text, startPosition, slice.Start - 1)) { DelimiterCount = delimiterCount, Type = delimiterType, @@ -221,7 +221,7 @@ private void ProcessEmphasis(InlineProcessor processor, List