-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
75 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
35 changes: 35 additions & 0 deletions
35
src/Microsoft.DocAsCode.MarkdownLite/Gfm/GfmHtmlCommentBlockRule.cs
This file contains 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,35 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.DocAsCode.MarkdownLite | ||
{ | ||
using System.Collections.Immutable; | ||
using System.Text.RegularExpressions; | ||
|
||
public class GfmHtmlCommentBlockRule : IMarkdownRule | ||
{ | ||
public virtual string Name => "GfmHtmlComment"; | ||
|
||
public virtual Regex HtmlComment => Regexes.Block.Gfm.HtmlComment; | ||
|
||
public virtual IMarkdownToken TryMatch(IMarkdownParser parser, ref string source) | ||
{ | ||
var match = HtmlComment.Match(source); | ||
if (match.Length == 0) | ||
{ | ||
return null; | ||
} | ||
source = source.Substring(match.Length); | ||
return new MarkdownHtmlBlockToken( | ||
this, | ||
parser.Context, | ||
new InlineContent( | ||
ImmutableArray.Create<IMarkdownToken>( | ||
new MarkdownRawToken( | ||
this, | ||
parser.Context, | ||
match.Value))), | ||
match.Value); | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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