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:
2026-01-25 01:47:47 +00:00
parent 5a4054ec66
commit 74ef5cbc11
74 changed files with 7749 additions and 292 deletions
+22
View File
@@ -0,0 +1,22 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var multiLine = Markdown.toHtml("```\nline 1\nline 2\nline 3\n```")
System.print(multiLine.contains("line 1")) // expect: true
System.print(multiLine.contains("line 2")) // expect: true
System.print(multiLine.contains("line 3")) // expect: true
System.print(multiLine.contains("<pre><code>")) // expect: true
var multiQuote = Markdown.toHtml("> line 1\n> line 2")
System.print(multiQuote.contains("<blockquote>")) // expect: true
System.print(multiQuote.contains("line 1")) // expect: true
System.print(multiQuote.contains("line 2")) // expect: true
var withLang = Markdown.toHtml("```wren\nSystem.print(\"hello\")\n```")
System.print(withLang.contains("<pre><code>")) // expect: true
System.print(withLang.contains("System.print")) // expect: true
var emptyBlock = Markdown.toHtml("```\n\n```")
System.print(emptyBlock.contains("<pre><code>")) // expect: true
System.print(emptyBlock.contains("</code></pre>")) // expect: true
+24
View File
@@ -0,0 +1,24 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
System.print(Markdown.toHtml("__bold underscore__")) // expect: <p><strong>bold underscore</strong></p>
var mixed = Markdown.toHtml("This is **bold** and *italic* text")
System.print(mixed.contains("<strong>bold</strong>")) // expect: true
System.print(mixed.contains("<em>italic</em>")) // expect: true
var code = Markdown.toHtml("Use `print()` function")
System.print(code.contains("<code>print()</code>")) // expect: true
var multi = Markdown.toHtml("**bold** and `code` and *italic*")
System.print(multi.contains("<strong>bold</strong>")) // expect: true
System.print(multi.contains("<code>code</code>")) // expect: true
System.print(multi.contains("<em>italic</em>")) // expect: true
var unclosed = Markdown.toHtml("This has *unclosed italic")
System.print(unclosed.contains("<p>")) // expect: true
var empty = Markdown.toHtml("**bold****more**")
System.print(empty.contains("<strong>bold</strong>")) // expect: true
System.print(empty.contains("<strong>more</strong>")) // expect: true
+49
View File
@@ -0,0 +1,49 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
System.print(Markdown.fromHtml("<h1>Title</h1>")) // expect: # Title
System.print(Markdown.fromHtml("<h2>Subtitle</h2>")) // expect: ## Subtitle
System.print(Markdown.fromHtml("<h3>Section</h3>")) // expect: ### Section
System.print(Markdown.fromHtml("<h4>Subsection</h4>")) // expect: #### Subsection
System.print(Markdown.fromHtml("<h5>Minor</h5>")) // expect: ##### Minor
System.print(Markdown.fromHtml("<h6>Smallest</h6>")) // expect: ###### Smallest
System.print(Markdown.fromHtml("<strong>bold</strong>")) // expect: **bold**
System.print(Markdown.fromHtml("<b>bold</b>")) // expect: **bold**
System.print(Markdown.fromHtml("<em>italic</em>")) // expect: *italic*
System.print(Markdown.fromHtml("<i>italic</i>")) // expect: *italic*
System.print(Markdown.fromHtml("<code>code</code>")) // expect: `code`
System.print(Markdown.fromHtml("<del>deleted</del>")) // expect: ~~deleted~~
System.print(Markdown.fromHtml("<s>strike</s>")) // expect: ~~strike~~
System.print(Markdown.fromHtml("<a href=\"https://example.com\">Example</a>")) // expect: [Example](https://example.com)
System.print(Markdown.fromHtml("<img src=\"image.png\" alt=\"My Image\">")) // expect: ![My Image](image.png)
var ul = Markdown.fromHtml("<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>")
System.print(ul.contains("- Item 1")) // expect: true
System.print(ul.contains("- Item 2")) // expect: true
System.print(ul.contains("- Item 3")) // expect: true
var ol = Markdown.fromHtml("<ol><li>First</li><li>Second</li><li>Third</li></ol>")
System.print(ol.contains("1. First")) // expect: true
System.print(ol.contains("2. Second")) // expect: true
System.print(ol.contains("3. Third")) // expect: true
var bq = Markdown.fromHtml("<blockquote>Quote text</blockquote>")
System.print(bq.contains("> Quote text")) // expect: true
System.print(Markdown.fromHtml("<hr>").contains("---")) // expect: true
System.print(Markdown.fromHtml("<hr/>").contains("---")) // expect: true
var p = Markdown.fromHtml("<p>First paragraph</p><p>Second paragraph</p>")
System.print(p.contains("First paragraph")) // expect: true
System.print(p.contains("Second paragraph")) // expect: true
var br = Markdown.fromHtml("Line one<br>Line two")
System.print(br.contains("Line one")) // expect: true
System.print(br.contains("Line two")) // expect: true
+78
View File
@@ -0,0 +1,78 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var nested = Markdown.fromHtml("<p><strong>Bold <em>and italic</em> text</strong></p>")
System.print(nested.contains("**Bold *and italic* text**")) // expect: true
var mixed = Markdown.fromHtml("<p>Normal <strong>bold</strong> and <em>italic</em> and <code>code</code></p>")
System.print(mixed.contains("Normal **bold** and *italic* and `code`")) // expect: true
var codeBlock = Markdown.fromHtml("<pre><code>function test() {\n return true;\n}</code></pre>")
System.print(codeBlock.contains("```")) // expect: true
System.print(codeBlock.contains("function test()")) // expect: true
var script = Markdown.fromHtml("<p>Hello</p><script>alert('xss');</script><p>World</p>")
System.print(script.contains("Hello")) // expect: true
System.print(script.contains("World")) // expect: true
System.print(script.contains("alert")) // expect: false
System.print(script.contains("script")) // expect: false
var style = Markdown.fromHtml("<p>Content</p><style>.red { color: red; }</style>")
System.print(style.contains("Content")) // expect: true
System.print(style.contains("color")) // expect: false
var entities = Markdown.fromHtml("<p>5 &gt; 3 &amp;&amp; 3 &lt; 5</p>")
System.print(entities.contains(">")) // expect: true
System.print(entities.contains("<")) // expect: true
System.print(entities.contains("&")) // expect: true
var doc = """
<html>
<head><title>Test</title></head>
<body>
<h1>Main Title</h1>
<p>Introduction paragraph with <strong>bold</strong> text.</p>
<h2>Section One</h2>
<ul>
<li>Item A</li>
<li>Item B</li>
</ul>
<blockquote>A wise quote</blockquote>
<hr>
<p>Footer content</p>
</body>
</html>
"""
var result = Markdown.fromHtml(doc)
System.print(result.contains("# Main Title")) // expect: true
System.print(result.contains("**bold**")) // expect: true
System.print(result.contains("## Section One")) // expect: true
System.print(result.contains("- Item A")) // expect: true
System.print(result.contains("> A wise quote")) // expect: true
System.print(result.contains("---")) // expect: true
var linkNested = Markdown.fromHtml("<a href=\"/page\"><strong>Bold Link</strong></a>")
System.print(linkNested.contains("[**Bold Link**](/page)")) // expect: true
var container = Markdown.fromHtml("<div><section><article>Content</article></section></div>")
System.print(container.contains("Content")) // expect: true
System.print(container.contains("<div>")) // expect: false
System.print(container.contains("<section>")) // expect: false
System.print(Markdown.fromHtml("<img src=\"a.png\" alt=\"test\"/>").contains("![test](a.png)")) // expect: true
System.print(Markdown.fromHtml("<br/>").trim() == "") // expect: true
System.print(Markdown.fromHtml("<p></p>").trim() == "") // expect: true
System.print(Markdown.fromHtml("<strong></strong>").trim() == "****") // expect: true
var ws = Markdown.fromHtml("<p> spaced content </p>")
System.print(ws.contains("spaced content")) // expect: true
var multi = Markdown.fromHtml("<p>Para 1</p><p>Para 2</p><p>Para 3</p>")
var lines = multi.split("\n")
var nonEmpty = 0
for (line in lines) {
if (line.trim().count > 0) nonEmpty = nonEmpty + 1
}
System.print(nonEmpty >= 3) // expect: true
+11
View File
@@ -0,0 +1,11 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
System.print(Markdown.toHtml("---").contains("<hr>")) // expect: true
System.print(Markdown.toHtml("***").contains("<hr>")) // expect: true
System.print(Markdown.toHtml("___").contains("<hr>")) // expect: true
System.print(Markdown.toHtml("-----").contains("<hr>")) // expect: true
System.print(Markdown.toHtml("*****").contains("<hr>")) // expect: true
System.print(Markdown.toHtml("_____").contains("<hr>")) // expect: true
+21
View File
@@ -0,0 +1,21 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var multi = Markdown.toHtml("[First](http://a.com) and [Second](http://b.com)")
System.print(multi.contains("<a href=\"http://a.com\">First</a>")) // expect: true
System.print(multi.contains("<a href=\"http://b.com\">Second</a>")) // expect: true
var withPath = Markdown.toHtml("[Docs](/docs/api/index.html)")
System.print(withPath.contains("<a href=\"/docs/api/index.html\">Docs</a>")) // expect: true
var imgAlt = Markdown.toHtml("![A cat](cat.jpg)")
System.print(imgAlt.contains("<img src=\"cat.jpg\" alt=\"A cat\">")) // expect: true
var imgUrl = Markdown.toHtml("![Logo](https://example.com/logo.png)")
System.print(imgUrl.contains("<img src=\"https://example.com/logo.png\" alt=\"Logo\">")) // expect: true
var textAround = Markdown.toHtml("Click [here](url) now")
System.print(textAround.contains("Click ")) // expect: true
System.print(textAround.contains("<a href=\"url\">here</a>")) // expect: true
System.print(textAround.contains(" now")) // expect: true
+22
View File
@@ -0,0 +1,22 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var star = Markdown.toHtml("* item a\n* item b")
System.print(star.contains("<ul>")) // expect: true
System.print(star.contains("<li>item a</li>")) // expect: true
System.print(star.contains("<li>item b</li>")) // expect: true
var plus = Markdown.toHtml("+ item x\n+ item y")
System.print(plus.contains("<ul>")) // expect: true
System.print(plus.contains("<li>item x</li>")) // expect: true
System.print(plus.contains("<li>item y</li>")) // expect: true
var multiDigit = Markdown.toHtml("10. tenth\n11. eleventh")
System.print(multiDigit.contains("<ol>")) // expect: true
System.print(multiDigit.contains("<li>tenth</li>")) // expect: true
System.print(multiDigit.contains("<li>eleventh</li>")) // expect: true
var formatted = Markdown.toHtml("- **bold item**\n- *italic item*")
System.print(formatted.contains("<li><strong>bold item</strong></li>")) // expect: true
System.print(formatted.contains("<li><em>italic item</em></li>")) // expect: true
+40
View File
@@ -0,0 +1,40 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var doc = "# Title
This is a paragraph with **bold** text.
- Item 1
- Item 2
Another paragraph.
> A quote
---
## Subtitle
1. First
2. Second"
var html = Markdown.toHtml(doc)
System.print(html.contains("<h1>Title</h1>")) // expect: true
System.print(html.contains("<strong>bold</strong>")) // expect: true
System.print(html.contains("<ul>")) // expect: true
System.print(html.contains("<li>Item 1</li>")) // expect: true
System.print(html.contains("<blockquote>")) // expect: true
System.print(html.contains("<hr>")) // expect: true
System.print(html.contains("<h2>Subtitle</h2>")) // expect: true
System.print(html.contains("<ol>")) // expect: true
System.print(html.contains("<li>First</li>")) // expect: true
var linkInList = Markdown.toHtml("- [Link](http://example.com)")
System.print(linkInList.contains("<li>")) // expect: true
System.print(linkInList.contains("<a href=\"http://example.com\">Link</a>")) // expect: true
var codeInHeading = Markdown.toHtml("# Using `print()`")
System.print(codeInHeading.contains("<h1>")) // expect: true
System.print(codeInHeading.contains("<code>print()</code>")) // expect: true
+17
View File
@@ -0,0 +1,17 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var p = Markdown.toHtml("This is a paragraph.")
System.print(p) // expect: <p>This is a paragraph.</p>
var multi = Markdown.toHtml("First paragraph.\n\nSecond paragraph.")
System.print(multi.contains("<p>First paragraph.</p>")) // expect: true
System.print(multi.contains("<p>Second paragraph.</p>")) // expect: true
var afterHeading = Markdown.toHtml("# Title\n\nSome text here.")
System.print(afterHeading.contains("<h1>Title</h1>")) // expect: true
System.print(afterHeading.contains("<p>Some text here.</p>")) // expect: true
var empty = Markdown.toHtml("")
System.print(empty) // expect:
+21
View File
@@ -0,0 +1,21 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var unsafe = Markdown.toHtml("<script>alert('xss')</script>")
System.print(unsafe.contains("<script>")) // expect: true
var safe = Markdown.toHtml("<script>alert('xss')</script>", {"safeMode": true})
System.print(safe.contains("<script>")) // expect: false
System.print(safe.contains("&lt;script&gt;")) // expect: true
var safeCode = Markdown.toHtml("```\n<div>test</div>\n```", {"safeMode": true})
System.print(safeCode.contains("<div>")) // expect: false
System.print(safeCode.contains("&lt;div&gt;")) // expect: true
var safeInline = Markdown.toHtml("Text with <b>html</b> inside", {"safeMode": true})
System.print(safeInline.contains("<b>")) // expect: false
System.print(safeInline.contains("&lt;b&gt;")) // expect: true
var ampersand = Markdown.toHtml("A & B", {"safeMode": true})
System.print(ampersand.contains("&amp;")) // expect: true