Skip to content

Commit

Permalink
Add a new option
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMagnan committed Nov 11, 2024
1 parent 77ae081 commit bcf51cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/HtmlAgilityPack.Shared/HtmlDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ public static bool DisableBehaviorTagP
/// </summary>
public int OptionMaxNestedChildNodes = 0;

/// <summary>
/// Enable to create a "new line" for tag such as "br"
/// </summary>
public bool OptionEnableBreakLineForInnerText;


#endregion

Expand Down
6 changes: 6 additions & 0 deletions src/HtmlAgilityPack.Shared/HtmlNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ internal virtual void InternalInnerText(StringBuilder sb, bool isDisplayScriptin
return;
}

if (_ownerdocument.OptionEnableBreakLineForInnerText && Name == "br")
{
sb.AppendLine();
return;
}

if (_nodetype == HtmlNodeType.Text)
{
sb.Append(((HtmlTextNode) this).Text);
Expand Down

0 comments on commit bcf51cc

Please sign in to comment.