Skip to content

Commit

Permalink
add tags: <b>, <abbr>
Browse files Browse the repository at this point in the history
  • Loading branch information
Maniceraf committed Jun 14, 2024
1 parent 62f08c8 commit af85fbf
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
9 changes: 8 additions & 1 deletion EasyHtmlToolkit.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ public class Program
{
static void Main(string[] args)
{

var b = new BTag("and this is bold text");
var p = new PTag($"This is normal text - {b}.");

var doc = new HtmlDocument();

doc.Body.AddChildren(p);

doc.SaveToDownloadsFolder();
}

public static void Example1()
Expand Down
6 changes: 6 additions & 0 deletions EasyHtmlToolkit/Enums/ETag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,11 @@ public enum ETag

[Description("img")]
img = 13,

[Description("b")]
b = 14,

[Description("abbr")]
abbr = 15,
}
}
2 changes: 1 addition & 1 deletion EasyHtmlToolkit/Extensions/FileMinimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace EasyHtmlToolkit.Extensions
{
public class FileMinimizer
{
public string GetMinimizedFileContent(string filePath)
public string? GetMinimizedFileContent(string filePath)
{
try
{
Expand Down
40 changes: 40 additions & 0 deletions EasyHtmlToolkit/Models/Elements/AbbrTag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using EasyHtmlToolkit.Enums;

namespace EasyHtmlToolkit.Models.Elements
{
/// <summary>
/// Represents an HTML <abbr> (abbreviation) element.
/// </summary>
public class AbbrTag : HtmlElement
{
/// <summary>
/// Initializes a new instance of the <see cref="AbbrTag"/> class.
/// </summary>
public AbbrTag() : base(ETag.abbr) { }

/// <summary>
/// Initializes a new instance of the <see cref="AbbrTag"/> class with the specified inner text and optional title attribute.
/// </summary>
/// <param name="innerText">The inner text of the <abbr> element.</param>
/// <param name="title">The optional title attribute of the <abbr> element.</param>
public AbbrTag(string innerText, string? title = null) : base(ETag.abbr)
{
InnerText = innerText;

if (!string.IsNullOrEmpty(title))
{
AddAttribute("title", title);
}
}

/// <summary>
/// Sets the title attribute value of the <abbr> element.
/// </summary>
/// <param name="title">The title attribute value.</param>
public void SetTitle(string title)
{
AddAttribute("title", title);
}
}

}
24 changes: 24 additions & 0 deletions EasyHtmlToolkit/Models/Elements/BTag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using EasyHtmlToolkit.Enums;

namespace EasyHtmlToolkit.Models.Elements
{
/// <summary>
/// Represents an HTML <b> (bold) element.
/// </summary>
public class BTag : HtmlElement
{
/// <summary>
/// Initializes a new instance of the <see cref="BTag"/> class.
/// </summary>
public BTag() : base(ETag.b) { }

/// <summary>
/// Initializes a new instance of the <see cref="BTag"/> class with the specified inner text.
/// </summary>
/// <param name="innerText">The inner text of the <b> element.</param>
public BTag(string innerText) : base(ETag.b)
{
InnerText = innerText;
}
}
}

0 comments on commit af85fbf

Please sign in to comment.