Skip to content

Conversation

@tats-u
Copy link

@tats-u tats-u commented Nov 13, 2025

Fixes #860

}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsWhitespace(this Rune r) => r.IsBmp && IsWhitespace((char)r.Value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make these new helpers internal.

No two specs agree on what space means, so I'd avoid exposing more ambiguous extensions on common types (it's not obvious this is CommonMark-specific).

(same for all new helpers in this file)

}

#if !(NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER)
private static Lazy<Func<int, UnicodeCategory>?> GetUnicodeCategoryReflection =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should fallback to CharUnicodeInfo.GetUnicodeCategory(value.ToString(), 0) instead.
It's the same thing that .NET itself uses in its Rune impl for Framework.

https://github.com/dotnet/runtime/blob/d594a04c1a2426ef295448c756f55965dedfc044/src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs#L1279-L1287

Comment on lines +147 to +150
if (start < 1) return default;
var trueFirst = Text[start - 1];
if (!char.IsHighSurrogate(trueFirst)) return default;
return new Rune(trueFirst, first);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a usage error, I would avoid reading backwards in these helpers.
(same for all of these)

Comment on lines +31 to +33
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Shim.System.Text.Rune" Version="6.0.2" />
</ItemGroup>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the new dependency, we should polyfill the required Rune logic instead
https://github.com/xoofx/markdig/tree/master/src/Markdig/Polyfills

The new Rune helpers on StringSlice can be internal (or at least internal on targets without Rune in the base libraries).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recognize supplementary (non-BMP) punctuations around emphasis delimiter runs

2 participants