Žiadny popis

Kitt Parker c454e0766e update 4 mesiacov pred
HTMLTextAttribute.cs 4bc2f1838c First Commit 4 mesiacov pred
HTMLUtility.cs 4bc2f1838c First Commit 4 mesiacov pred
README.md c454e0766e update 4 mesiacov pred

README.md

🧰 Acumatica HTML Utility

A lightweight helper class for Acumatica customizations and extensions that need to process, sanitize, or extract readable text from HTML content.


📄 Overview

HtmlUtilities provides static helper methods for converting HTML strings to plain text, counting words, and truncating text safely.
It leverages the HtmlAgilityPack library to parse and traverse HTML nodes efficiently, ensuring that only meaningful content is preserved.

This utility is particularly useful for Acumatica developers dealing with HTML-based user inputs, API responses, or custom field rendering.


✨ Features

  • ConvertToPlainText — Removes HTML tags and extracts clean text.
  • CountWords — Counts words in a plain text string.
  • Cut — Safely trims a string to a specified length and appends ellipses (...) when needed.
  • Smart Parsing — Ignores <script> and <style> blocks and preserves paragraph/line breaks.

🧩 Example Usage

```csharp using PX.Data;

string html = "

Hello Acumatica Developer!

"; string plain = HtmlUtilities.ConvertToPlainText(html); // plain => "Hello Acumatica Developer!"

int wordCount = HtmlUtilities.CountWords(plain); // wordCount => 3

string shortened = HtmlUtilities.Cut(plain, 10); // shortened => "Hello ..."