diff --git a/src/Markdig.Tests/TestEmphasisExtended.cs b/src/Markdig.Tests/TestEmphasisExtended.cs index ce6c8973..c95fc5e3 100644 --- a/src/Markdig.Tests/TestEmphasisExtended.cs +++ b/src/Markdig.Tests/TestEmphasisExtended.cs @@ -148,6 +148,9 @@ class CustomEmphasisInline : EmphasisInline { } [TestCase("1Foo1", "Foo")] [TestCase("1121", "12")] [TestCase("22322", "3")] + [TestCase("2223222", "232")] + [TestCase("22223222", "2232")] + [TestCase("22223223222", "2222332")] [TestCase("2232", "2232")] [TestCase("333", "333")] [TestCase("3334333", "4")] diff --git a/src/Markdig/Helpers/UnicodeUtility.cs b/src/Markdig/Helpers/UnicodeUtility.cs index 4364c953..2c059afc 100644 --- a/src/Markdig/Helpers/UnicodeUtility.cs +++ b/src/Markdig/Helpers/UnicodeUtility.cs @@ -22,7 +22,7 @@ public static bool IsValidUnicodeScalar(uint value) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void GetUtf16SurrogatesFromSupplementaryPlaneScalar(uint value, out char highSurrogateCodePoint, out char lowSurrogateCodePoint) { - Debug.Assert(IsValidUnicodeScalar(value) && IsBmpCodePoint(value)); + Debug.Assert(IsValidUnicodeScalar(value) && !IsBmpCodePoint(value)); highSurrogateCodePoint = (char)((value + ((0xD800u - 0x40u) << 10)) >> 10); lowSurrogateCodePoint = (char)((value & 0x3FFu) + 0xDC00u); diff --git a/src/Markdig/Parsers/Inlines/EmphasisDescriptor.cs b/src/Markdig/Parsers/Inlines/EmphasisDescriptor.cs index c2e8259e..429a24b1 100644 --- a/src/Markdig/Parsers/Inlines/EmphasisDescriptor.cs +++ b/src/Markdig/Parsers/Inlines/EmphasisDescriptor.cs @@ -3,12 +3,14 @@ // See the license.txt file in the project root for more information. using Markdig.Helpers; +using System.Diagnostics; namespace Markdig.Parsers.Inlines; /// /// Descriptor for an emphasis. /// +[DebuggerDisplay("Emphasis Char={Character}, Min={MinimumCount}, Max={MaximumCount}, EnableWithinWord={EnableWithinWord}")] public sealed class EmphasisDescriptor { /// diff --git a/src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs b/src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs index 440a878b..af2921c8 100644 --- a/src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs +++ b/src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs @@ -233,9 +233,9 @@ private void ProcessEmphasis(InlineProcessor processor, List= emphasisDesc.MinimumCount) + if ((closeDelimiter.Type & DelimiterType.Close) != 0) { - while (true) + while (closeDelimiter.DelimiterCount >= emphasisDesc.MinimumCount) { // Now, look back in the stack (staying above stack_bottom and the openers_bottom for this delimiter type) // for the first matching potential opener (“matching” means same delimiter). @@ -245,8 +245,7 @@ private void ProcessEmphasis(InlineProcessor processor, List= emphasisDesc.MinimumCount) + if (openDelimiter.DelimiterCount >= emphasisDesc.MinimumCount && + closeDelimiter.DelimiterCount >= emphasisDesc.MinimumCount) { goto process_delims; }