Skip to content

[Feature]: Plain text with normalized whitespace from AttributeValueXHTML  #92

Closed

Description

@samatstariongroup

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the reqifsharp
  • I have searched open and closed issues to ensure it has not already been reported

Description

AttributeValueXHTML.ExtractUnformattedTextFromValue() returns the text with the line breaks and indentation of the XHTML source, and with extra spaces around inline elements. Every consumer that shows the text in a list, a label or a CSV has to clean it up; the ReqIF Viewer now does this itself.

Proposal

  • An option or a second method that returns normalized text: whitespace runs collapsed to one space, no space added before punctuation that follows an inline element, trimmed; paragraph and list boundaries optionally kept as a line break.

Acceptance criteria

  • The example below gives "brew a cup in under 30 seconds."; the existing method keeps its behaviour.

Steps to Reproduce

var value = new AttributeValueXHTML
{
    TheValue = "<xhtml:div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"><xhtml:p>brew a cup in <xhtml:b>under 30 seconds</xhtml:b>.</xhtml:p></xhtml:div>"
};
Console.WriteLine($"[{value.ExtractUnformattedTextFromValue()}]"); // [brew a cup in  under 30 seconds .]

System Configuration

  • reqifsharp version: ReqIFSharp 10.1.2, ReqIFSharp.Extensions 5.2.2
  • Environment (Operating system, version and so on): Windows 11
  • .NET Framework version: .NET 10
  • Additional information: Found while planning editing and export in the ReqIF Viewer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions