This repository was archived by the owner on Feb 25, 2026. It is now read-only.
-
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
Merged
WilliamABradley
merged 91 commits into
CommunityToolkit:master
from
WilliamABradley:MakeMarkdownUniversalAgain
Feb 14, 2018
Merged
Markdown + RSS Parser for .NET Standard, MarkdownTextBlock Style Improvements, Syntax Highlighting #1650
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
00f9e98
-Split the Markdown Parser from MarkdownTextBlock.
WilliamABradley 1e1600b
Made old MarkdownRenderedEventArgs obsolete.
WilliamABradley f68fec8
-Broke MarkdownTextBlock.cs into Categorised partial sections.
WilliamABradley 75ff445
Fixed Header.
WilliamABradley 900efc9
-Created MarkdownRendererBase from XamlRenderer, the initial cross pl…
WilliamABradley 9650653
Renamed XamlRenderer to UWPMarkdownRenderer, as it doesn't Render any…
WilliamABradley 432af33
-Made RenderBlocks virtual, it only gets overriden if it has to.
WilliamABradley b2d1385
Fixed missing Headers.
WilliamABradley 2f34ae2
Added ICodeBlockResolver and CodeBlockResolving event, a way to injec…
WilliamABradley 812e9e9
Fixed XML Comment, warned that Resolving events require Handled = true.
WilliamABradley c0aae98
-Restyled default MarkdownTextBlock brushes and layout, it is now mor…
WilliamABradley 7d6140c
Moved BlockUIElementCollection object and InlineCollection ojbect ins…
WilliamABradley 78bf888
-Added Automatic Markdown Code Block Syntax Highlighting!!! :) This w…
WilliamABradley 7b5c53f
-Moved Markdown and RSS Parsers to new Microsoft.Toolkit.Parsers proj…
WilliamABradley f133914
Merge branch 'master' into MakeMarkdownUniversalAgain
WilliamABradley 0ff9bc1
Fixed Namespace change issues.
WilliamABradley 6dc2ccf
-Cleaned up a lot of Markdown documents to make them look better and …
WilliamABradley 26f9f6c
Added License Header to ThemeListener
WilliamABradley c38d72c
-Updated CodeRenderer to use RichTextBlock and ColorCode-Universal, r…
WilliamABradley a848683
-Made MarkdownDocument more visible.
WilliamABradley 4c88633
-Improved InitialContent.md for MarkdownTextBlock Sample.
WilliamABradley 5ef17ca
Added Tooltips to Links.
WilliamABradley 2248a43
-Added Property to Enable Code Block Text Wrapping.
WilliamABradley 15dd257
Updated Documentation.
WilliamABradley 816952b
Small Tweaks.
WilliamABradley aabec2e
ProcessDocs now handles Microsoft Note Notation.
WilliamABradley 2cfa459
Updated Docs Metadata.
WilliamABradley 2aecb67
Merge branch 'master' into MakeMarkdownUniversalAgain
WilliamABradley 6b5b5a4
Fixed Unit Test Compile errors.
WilliamABradley d5ed7ae
-Made Common Internal, added externally used helpers to public static…
WilliamABradley b48b22c
-Added Obsoleted classes for Microsoft.Toolkit.Services, Microsoft.To…
WilliamABradley ba49e9c
-Made Markdown Blocks and Elements have a public constructor again, a…
WilliamABradley 70ae74e
Removed all remaining dependencies from obsolete StringValueAttribute…
WilliamABradley 8b934bf
Fixed VS warnings related to this PR.
WilliamABradley e5234e7
-Restuctured Markdown Parser folders and namespaces, now instead of M…
WilliamABradley ff71a18
Separated nested Classes and Enums to their own file.
WilliamABradley b8c3cb5
Fixed missing space.
WilliamABradley 17500c9
Removed UWP Prefix from UWPMarkdownRenderer.
WilliamABradley 3d0292b
Replaced ParseHelpers IsBlankOrWhitespace and IsWhiteSpace, with stri…
WilliamABradley 77b35b4
Revert "Replaced ParseHelpers IsBlankOrWhitespace and IsWhiteSpace, w…
WilliamABradley 6e5751b
Renamed ParseHelpers IsBlankOrWhiteSpace and IsWhiteSpace to IsMarkdo…
WilliamABradley 5747f40
Fixed Access modifiers for RSS classes that don't need to be exposed.
WilliamABradley 39cc0c4
Added Deprecation to Microsoft.Toolkit.Uwp.Services.Core.ExtensionMet…
WilliamABradley 054f088
Added Documentation for Markdown Parser, added LinkClicked event to d…
WilliamABradley da59db2
-Added ThemeListener Documentation.
WilliamABradley 1216f32
MarkdownTextBlock now will react to changes to RequestedTheme, as lon…
WilliamABradley caee71a
Improved Documentation.
WilliamABradley 6271453
Added Basic Rss and Json Parser documentation.
WilliamABradley 5a6c77e
Simplified Theme Checking.
WilliamABradley ef1ea23
-Added null checks to IRenderContext casting for UWP MarkdownRenderer…
WilliamABradley 6562cf9
Add null check to MarkdownTextBlock RenderMarkdown, for Types that ar…
WilliamABradley 3c3de6c
-Added Support for DocFX Notes in SampleAppMarkdownRenderer.
WilliamABradley 9e1ace2
Added extra Null Check.
WilliamABradley 2f4c55b
-Modified Sample.cs to only grab the latest copy only and cache in Re…
WilliamABradley e41e632
Fixed Documentation formatting issues related to Markdown correctness…
WilliamABradley fcb4b16
Fixed all but one pesky Unit Test.
WilliamABradley cb5c310
Fixed the last Pesky Unit Test.
WilliamABradley 912b229
-Code Blocks now only semi-broken in ListBlock. Need to escape Tab ch…
WilliamABradley b346c6c
Fixed ListBlock swallowing any extra Whitespace.
WilliamABradley 6b37dd4
-Restored Animation Docs to their former Glory, with more correct for…
WilliamABradley 0c22cef
Made DocFX Notation formatting in line with docs.microsoft.com.
WilliamABradley 612be34
Merge branch 'master' of https://github.com/Microsoft/UWPCommunityToo…
WilliamABradley 524733a
Added Parser Documentation improvements.
WilliamABradley 6ee4b01
-Added LinkReferenceInline in the Parser, a way to collect <a> HTML t…
WilliamABradley 369ee04
Internalised JsonParser, I don't see it used anywhere, but it might b…
WilliamABradley 7b40e2d
-Added better examples to RSS and Markdown Docs.
WilliamABradley 18ab2ba
-Removed Comments from StaggeredPanel.
WilliamABradley ecf3644
Added Properties and Methods to RSSParser and MarkdownParser docs.
WilliamABradley 689f817
Merge branch 'master' into MakeMarkdownUniversalAgain
WilliamABradley 4448985
Fixed FrameworkElementExtensions docs.
WilliamABradley 852ee7a
Merge branch 'master' of https://github.com/Microsoft/UWPCommunityToo…
WilliamABradley c1a65f0
-Fixed bug in BoldItalicTextInline.
WilliamABradley 1d9ea98
Disabled the ThemeListener Sample for the time being.
WilliamABradley e194a21
Reverted most of the changes to the Animation Documentation.
WilliamABradley 4d2ef94
Yet another fix for ListBlock logic.
WilliamABradley 0b00a06
Fixed HamburgerMenu nav link.
WilliamABradley 623479a
More Doc fixes.
WilliamABradley 2d2bf1d
Fixed naming conventions and locations for Markdown Docs.
WilliamABradley b4b1dec
-Simplified SampleAppMarkdownRenderer structure, added extra comments…
WilliamABradley 02155bd
Merge branch 'master' of https://github.com/Microsoft/UWPCommunityToo…
WilliamABradley 8e320fa
Fixed VS complaints.
WilliamABradley d5911c4
Merge branch 'master' of https://github.com/Microsoft/UWPCommunityToo…
WilliamABradley dca5553
Renamed LinkReferenceInline to LinkAnchorInline, as it is a more fit…
WilliamABradley d078053
Fixed more VS complaints.
WilliamABradley 3212cb6
Merged changes from UWPCommunityToolkit/Master into MakeMarkdownUnive…
WilliamABradley 2c96d80
Merged UWPCommunityToolkit/Master into MakeMarkdownUniversalAgain.
WilliamABradley 3137573
-Moved Extension methods to StringExtensions.
WilliamABradley 929121e
Merge branch 'master' of https://github.com/Microsoft/UWPCommunityToo…
WilliamABradley 36fb178
Fixed some more things.
WilliamABradley f4901eb
-Fixed naming and descriptions of StringExtensions.
WilliamABradley 5faa708
-Added tests to MD test playlist.
WilliamABradley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
Member
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.
Contributor
Author
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; } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.