This commit is contained in:
2026-01-26 10:21:03 +01:00
parent fe2f087d9f
commit fbc1a6e294
40 changed files with 3478 additions and 547 deletions
+31
View File
@@ -0,0 +1,31 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var httpUrl = "Visit https://example.com for info"
var httpHtml = Markdown.toHtml(httpUrl)
System.print(httpHtml.contains("<a href=\"https://example.com\">https://example.com</a>")) // expect: true
var httpOnly = "Check http://test.org/path"
var httpOnlyHtml = Markdown.toHtml(httpOnly)
System.print(httpOnlyHtml.contains("<a href=\"http://test.org/path\">http://test.org/path</a>")) // expect: true
var email = "Contact user@example.com today"
var emailHtml = Markdown.toHtml(email)
System.print(emailHtml.contains("mailto:user@example.com")) // expect: true
System.print(emailHtml.contains(">user@example.com</a>")) // expect: true
var noAutolink = "[Link](https://example.com)"
var noAutolinkHtml = Markdown.toHtml(noAutolink)
var count = 0
var i = 0
while (i < noAutolinkHtml.count - 4) {
if (noAutolinkHtml[i...i+5] == "href=") count = count + 1
i = i + 1
}
System.print(count) // expect: 1
var multiUrl = "See https://a.com and https://b.com"
var multiHtml = Markdown.toHtml(multiUrl)
System.print(multiHtml.contains("href=\"https://a.com\"")) // expect: true
System.print(multiHtml.contains("href=\"https://b.com\"")) // expect: true
+1 -1
View File
@@ -14,7 +14,7 @@ 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("<pre><code class=\"language-wren\">")) // expect: true
System.print(withLang.contains("System.print")) // expect: true
var emptyBlock = Markdown.toHtml("```\n\n```")
+27
View File
@@ -0,0 +1,27 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var js = "```javascript\nconst x = 1;\n```"
var jsHtml = Markdown.toHtml(js)
System.print(jsHtml.contains("class=\"language-javascript\"")) // expect: true
System.print(jsHtml.contains("const x = 1;")) // expect: true
var py = "```python\ndef foo():\n pass\n```"
var pyHtml = Markdown.toHtml(py)
System.print(pyHtml.contains("class=\"language-python\"")) // expect: true
System.print(pyHtml.contains("def foo():")) // expect: true
var noLang = "```\nplain code\n```"
var noLangHtml = Markdown.toHtml(noLang)
System.print(noLangHtml.contains("language-")) // expect: false
System.print(noLangHtml.contains("plain code")) // expect: true
var wren = "```wren\nSystem.print(\"Hello\")\n```"
var wrenHtml = Markdown.toHtml(wren)
System.print(wrenHtml.contains("class=\"language-wren\"")) // expect: true
var rust = "```rust\nfn main() {}\n```"
var rustHtml = Markdown.toHtml(rust)
System.print(rustHtml.contains("class=\"language-rust\"")) // expect: true
System.print(rustHtml.contains("<pre><code")) // expect: true
+27
View File
@@ -0,0 +1,27 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var basic = "| A | B |\n|---|---|\n| 1 | 2 |"
var html = Markdown.toHtml(basic)
System.print(html.contains("<table>")) // expect: true
System.print(html.contains("<thead>")) // expect: true
System.print(html.contains("<tbody>")) // expect: true
System.print(html.contains("<th>A</th>")) // expect: true
System.print(html.contains("<td>1</td>")) // expect: true
var aligned = "| Left | Center | Right |\n|:---|:---:|---:|\n| L | C | R |"
var alignedHtml = Markdown.toHtml(aligned)
System.print(alignedHtml.contains("text-align:center")) // expect: true
System.print(alignedHtml.contains("text-align:right")) // expect: true
var multiRow = "| H1 | H2 |\n|---|---|\n| A | B |\n| C | D |"
var multiHtml = Markdown.toHtml(multiRow)
System.print(multiHtml.contains("<td>A</td>")) // expect: true
System.print(multiHtml.contains("<td>D</td>")) // expect: true
var inlineTable = "| **Bold** | *Italic* |\n|---|---|\n| `code` | [link](url) |"
var inlineHtml = Markdown.toHtml(inlineTable)
System.print(inlineHtml.contains("<strong>Bold</strong>")) // expect: true
System.print(inlineHtml.contains("<em>Italic</em>")) // expect: true
System.print(inlineHtml.contains("<code>code</code>")) // expect: true
+29
View File
@@ -0,0 +1,29 @@
// retoor <retoor@molodetz.nl>
import "markdown" for Markdown
var unchecked = "- [ ] Task one"
var uncheckedHtml = Markdown.toHtml(unchecked)
System.print(uncheckedHtml.contains("task-list")) // expect: true
System.print(uncheckedHtml.contains("<input type=\"checkbox\" disabled>")) // expect: true
System.print(uncheckedHtml.contains("Task one")) // expect: true
var checked = "- [x] Done task"
var checkedHtml = Markdown.toHtml(checked)
System.print(checkedHtml.contains("<input type=\"checkbox\" disabled checked>")) // expect: true
System.print(checkedHtml.contains("Done task")) // expect: true
var mixed = "- [ ] Todo\n- [x] Complete\n- [ ] Another"
var mixedHtml = Markdown.toHtml(mixed)
System.print(mixedHtml.contains("Todo")) // expect: true
System.print(mixedHtml.contains("Complete")) // expect: true
System.print(mixedHtml.contains("Another")) // expect: true
var upperX = "- [X] Upper case X"
var upperHtml = Markdown.toHtml(upperX)
System.print(upperHtml.contains("checked")) // expect: true
var regular = "- Normal item"
var regularHtml = Markdown.toHtml(regular)
System.print(regularHtml.contains("task-list")) // expect: false
System.print(regularHtml.contains("<li>Normal item</li>")) // expect: true