Kitt Parker 4 kuukautta sitten
vanhempi
commit
c454e0766e
1 muutettua tiedostoa jossa 38 lisäystä ja 0 poistoa
  1. 38 0
      README.md

+ 38 - 0
README.md

@@ -0,0 +1,38 @@
+# 🧰 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`](https://html-agility-pack.net/) 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 = "<p>Hello <strong>Acumatica</strong> Developer!</p>";
+string plain = HtmlUtilities.ConvertToPlainText(html);
+// plain => "Hello Acumatica Developer!"
+
+int wordCount = HtmlUtilities.CountWords(plain);
+// wordCount => 3
+
+string shortened = HtmlUtilities.Cut(plain, 10);
+// shortened => "Hello ..."