- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.4k
Markdown + RSS Parser for .NET Standard, MarkdownTextBlock Style Improvements, Syntax Highlighting #1650
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
Markdown + RSS Parser for .NET Standard, MarkdownTextBlock Style Improvements, Syntax Highlighting #1650
Changes from all commits
00f9e98
              1e1600b
              f68fec8
              75ff445
              900efc9
              9650653
              432af33
              b2d1385
              2f34ae2
              812e9e9
              c0aae98
              7d6140c
              78bf888
              7b5c53f
              f133914
              0ff9bc1
              6dc2ccf
              26f9f6c
              c38d72c
              a848683
              4c88633
              5ef17ca
              2248a43
              15dd257
              816952b
              aabec2e
              2cfa459
              2aecb67
              6b5b5a4
              d5ed7ae
              b48b22c
              ba49e9c
              70ae74e
              8b934bf
              e5234e7
              ff71a18
              b8c3cb5
              17500c9
              3d0292b
              77b35b4
              6e5751b
              5747f40
              39cc0c4
              054f088
              da59db2
              1216f32
              caee71a
              6271453
              5a6c77e
              ef1ea23
              6562cf9
              3c3de6c
              9e1ace2
              2f4c55b
              e41e632
              fcb4b16
              cb5c310
              912b229
              b346c6c
              6b37dd4
              0c22cef
              612be34
              524733a
              6ee4b01
              369ee04
              7b40e2d
              18ab2ba
              ecf3644
              689f817
              4448985
              852ee7a
              c1a65f0
              1d9ea98
              e194a21
              4d2ef94
              0b00a06
              623479a
              2d2bf1d
              b4b1dec
              02155bd
              8e320fa
              d5911c4
              dca5553
              d078053
              3212cb6
              2c96d80
              3137573
              929121e
              36fb178
              f4901eb
              5faa708
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // ****************************************************************** | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // This code is licensed under the MIT License (MIT). | ||
| // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
| // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
| // ****************************************************************** | ||
|  | ||
| using System.Collections.Generic; | ||
|  | ||
| namespace Microsoft.Toolkit.Parsers | ||
| { | ||
| /// <summary> | ||
| /// Parser interface. | ||
| /// </summary> | ||
| /// <typeparam name="T">Type to parse into.</typeparam> | ||
| public interface IParser<out T> | ||
| where T : SchemaBase | ||
| { | ||
| /// <summary> | ||
| /// Parse method which all classes must implement. | ||
| /// </summary> | ||
| /// <param name="data">Data to parse.</param> | ||
| /// <returns>Strong typed parsed data.</returns> | ||
| IEnumerable<T> Parse(string data); | ||
| } | ||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -10,15 +10,16 @@ | |
| // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
| // ****************************************************************** | ||
|  | ||
| using Windows.UI.Xaml.Documents; | ||
|  | ||
| namespace Microsoft.Toolkit.Uwp.UI.Controls.Markdown.Display | ||
| namespace Microsoft.Toolkit.Parsers | ||
| { | ||
| /// <summary> | ||
| /// An internal interface used to handle links in the markdown. | ||
| /// Strong typed schema base class. | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be handy to have more details here on what this is used for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is used by the RSS Parser, and some of the Services like Bing? It is a base class for Schema based parsers. | ||
| /// </summary> | ||
| internal interface ILinkRegister | ||
| public abstract class SchemaBase | ||
| { | ||
| void RegisterNewHyperLink(Hyperlink newHyperlink, string linkUrl); | ||
| /// <summary> | ||
| /// Gets or sets identifier for strong typed record. | ||
| /// </summary> | ||
| public string InternalID { get; set; } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // ****************************************************************** | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // This code is licensed under the MIT License (MIT). | ||
| // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
| // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
| // ****************************************************************** | ||
|  | ||
| using System; | ||
|  | ||
| namespace Microsoft.Toolkit.Parsers.Core | ||
| { | ||
| /// <summary> | ||
| /// The StringValue attribute is used as a helper to decorate enum values with string representations. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Field)] | ||
| public sealed class StringValueAttribute : Attribute | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="StringValueAttribute"/> class. | ||
| /// Constructor accepting string value. | ||
| /// </summary> | ||
| /// <param name="value">String value</param> | ||
| public StringValueAttribute(string value) | ||
| { | ||
| Value = value; | ||
| } | ||
|  | ||
| /// <summary> | ||
| /// Gets property for string value. | ||
| /// </summary> | ||
| public string Value { get; } | ||
| } | ||
| } | 
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.
Seems like this class is only public just so this method can be used in in the controls project. And it seems like string.IsNullOrWhitespace could be just as easily used.
Uh oh!
There was an error while loading. Please reload this page.
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 checks for tabs as whitespace as well, which I am not sure is done by the string.IsNullOrWhitespace method.
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.
string.IsNullOrWhiteSpace also checks for tab
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.
Hmm, weird, I looked as mscorlib with dotPeek, and it looks like it does check for tab chars, I wonder why this was duplicated? @paulbartrum be advised if you implemented this, will this break anything?
Uh oh!
There was an error while loading. Please reload this page.
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.
The markdown spec says:
A whitespace character is a space (U+0020), tab (U+0009), newline (U+000A), line tabulation (U+000B), form feed (U+000C), or carriage return (U+000D).
char.IsWhiteSpace()matches many many, more characters than just those six.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.
My two cents: these methods are implementation details of the markdown parser, they should be internal if possible (even if the parser itself is public).
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.
Microsoft.Toolkit.Uwp.UI.Controls.Markdown.Render.MarkdownRenderer has a dependency on IsBlankOrWhiteSpace, which is the reason it is public.
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 the change in 6e5751b makes it viable to keep it public.
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.
Any reason why the renderer would need access to the parser helpers?
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.
It is used in a workaround for UWP, other use cases might need this function.