-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
1 parent
3529fac
commit 1c014c5
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/ReverseMarkdown.Test/ConverterTests.When_Sup_And_Nested_Sup.md
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 @@ | ||
This is the 1^st^ sentence to t^es^t the sup tag conversion |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Linq; | ||
using HtmlAgilityPack; | ||
|
||
namespace ReverseMarkdown.Converters | ||
{ | ||
public class Sup : ConverterBase | ||
{ | ||
public Sup(Converter converter) : base(converter) | ||
{ | ||
Converter.Register("sup", this); | ||
} | ||
|
||
public override string Convert(HtmlNode node) | ||
{ | ||
var content = TreatChildren(node); | ||
if (string.IsNullOrEmpty(content) || AlreadySup(node)) | ||
{ | ||
return content; | ||
} | ||
else | ||
{ | ||
return $"^{content.Trim().Chomp(all:true)}^"; | ||
} | ||
} | ||
|
||
private static bool AlreadySup(HtmlNode node) | ||
{ | ||
return node.Ancestors("sup").Any(); | ||
} | ||
} | ||
} |