-
-
Notifications
You must be signed in to change notification settings - Fork 497
Recognize supplementary characters #913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static bool IsWhitespace(this Rune r) => r.IsBmp && IsWhitespace((char)r.Value); |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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.
| if (start < 1) return default; | ||
| var trueFirst = Text[start - 1]; | ||
| if (!char.IsHighSurrogate(trueFirst)) return default; | ||
| return new Rune(trueFirst, first); |
There was a problem hiding this comment.
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)
| <ItemGroup Condition=" '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1'"> | ||
| <PackageReference Include="Shim.System.Text.Rune" Version="6.0.2" /> | ||
| </ItemGroup> |
There was a problem hiding this comment.
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).
Fixes #860