feat: add merge_all_wren utility, strutil demo, and 7 new API manual pages
Add WrenFileReader class in apps/merge_all_wren.wren for recursive .wren file discovery and content printing. Introduce example/strutil_demo.wren demonstrating case conversion, hex encoding, SHA256 hashing, string repetition, padding, HTML/JSON escaping, and URL encoding/decoding. Create manual/api pages for argparse, dataset, html, markdown, uuid, wdantic, and web modules. Update manual/api/index.html sidebar and module count from 21 to 28, adding links and cards for the new modules.
This commit is contained in:
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "strutil" for Str
|
||||
import "crypto" for Hash
|
||||
|
||||
System.print("=== String Utility Module Demo ===\n")
|
||||
|
||||
System.print("--- Case Conversion ---")
|
||||
System.print("toLower('HELLO World'): " + Str.toLower("HELLO World"))
|
||||
System.print("toUpper('hello world'): " + Str.toUpper("hello world"))
|
||||
|
||||
System.print("\n--- Hex Encoding ---")
|
||||
var data = "ABC"
|
||||
var hex = Str.hexEncode(data)
|
||||
System.print("hexEncode('ABC'): " + hex)
|
||||
System.print("hexDecode('" + hex + "'): " + Str.hexDecode(hex))
|
||||
|
||||
System.print("\n--- SHA256 Hash with Hex ---")
|
||||
var hash = Hash.sha256("hello")
|
||||
System.print("SHA256('hello'): " + Hash.toHex(hash))
|
||||
|
||||
System.print("\n--- String Repetition ---")
|
||||
System.print("repeat('ab', 5): " + Str.repeat("ab", 5))
|
||||
|
||||
System.print("\n--- Padding ---")
|
||||
System.print("padLeft('42', 5, '0'): " + Str.padLeft("42", 5, "0"))
|
||||
System.print("padRight('x', 5, '-'): " + Str.padRight("x", 5, "-"))
|
||||
|
||||
System.print("\n--- HTML Escaping ---")
|
||||
var html = "<script>alert('xss')</script>"
|
||||
System.print("Original: " + html)
|
||||
System.print("Escaped: " + Str.escapeHtml(html))
|
||||
|
||||
System.print("\n--- JSON Escaping ---")
|
||||
var text = "Line 1\nLine 2\tTabbed"
|
||||
System.print("Original: Line 1\\nLine 2\\tTabbed")
|
||||
System.print("Escaped: " + Str.escapeJson(text))
|
||||
|
||||
System.print("\n--- URL Encoding ---")
|
||||
var url = "hello world & more"
|
||||
var encoded = Str.urlEncode(url)
|
||||
System.print("Original: " + url)
|
||||
System.print("Encoded: " + encoded)
|
||||
System.print("Decoded: " + Str.urlDecode(encoded))
|
||||
Reference in New Issue
Block a user