-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #349 from baynezy/feature/issue-331-code-syntax
feature/issue 331 code syntax
- Loading branch information
Showing
100 changed files
with
650 additions
and
57 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/Html2Markdown/Replacement/CommonMark/CommonMarkLayoutReplacementGroup.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,47 @@ | ||
namespace Html2Markdown.Replacement.CommonMark; | ||
|
||
/// <summary> | ||
/// A group of IReplacer to deal with converting HTML that is | ||
/// used for layout | ||
/// </summary> | ||
public class CommonMarkLayoutReplacementGroup : IReplacementGroup | ||
{ | ||
private readonly IList<IReplacer> _replacements = new List<IReplacer> { | ||
new PatternReplacer | ||
{ | ||
Pattern = "<hr[^>]*>", | ||
Replacement = Environment.NewLine + Environment.NewLine + "* * *" + Environment.NewLine | ||
}, | ||
new CustomReplacer | ||
{ | ||
CustomAction = ReplaceCode | ||
}, | ||
new CustomReplacer | ||
{ | ||
CustomAction = HtmlParser.ReplacePre | ||
}, | ||
new CustomReplacer | ||
{ | ||
CustomAction = HtmlParser.ReplaceParagraph | ||
}, | ||
new PatternReplacer | ||
{ | ||
Pattern = "<br[^>]*>", | ||
Replacement = " " + Environment.NewLine | ||
}, | ||
new CustomReplacer | ||
{ | ||
CustomAction = HtmlParser.ReplaceBlockquote | ||
} | ||
}; | ||
|
||
private static string ReplaceCode(string html) | ||
{ | ||
return HtmlParser.ReplaceCode(html, true); | ||
} | ||
|
||
public IEnumerable<IReplacer> Replacers() | ||
{ | ||
return _replacements; | ||
} | ||
} |
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
Oops, something went wrong.