feat: add wasm build targets, profile hooks, os_demo example, and restructure manual source
- Add `wasm`, `wasm-clean`, and `install-emscripten` phony targets to Makefile for WebAssembly cross-compilation
- Insert `WREN_PROFILE_ENTER`/`WREN_PROFILE_EXIT` macros in `wren_vm.h` and `wren_vm.c` to support optional runtime profiling via `WREN_PROFILE_ENABLED`
- Create `example/os_demo.wren` demonstrating Platform, Process, and conditional exit usage
- Update `example/regex_demo.wren` to import `Match` and exercise Match object properties, groups, and `matchAll`
- Remove static HTML manual pages (`base64.html`, `dns.html`, `json.html`) and replace with structured `manual_src/` directory containing Jinja2 templates, YAML metadata, and content pages
- Expand `README.md` with build targets table, manual building instructions, source layout, and guide for adding new module documentation
2026-01-26 05:12:14 +01:00
{# retoor < retoor @ molodetz . nl > #}
{% extends 'page.html' %}
{% set page_title = "markdown" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "markdown"}] %}
{% set prev_page = {"url": "api/dataset.html", "title": "dataset"} %}
{% set next_page = {"url": "api/web.html", "title": "web"} %}
{% block article %}
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.
2026-01-25 02:47:47 +01:00
< h1 > markdown< / h1 >
2026-01-26 10:21:03 +01:00
< p > The < code > markdown< / code > module provides bidirectional conversion between Markdown and HTML. It supports common Markdown syntax including headings, emphasis, code blocks, lists, links, images, and GitHub Flavored Markdown (GFM) extensions like tables, task lists, and autolinks.< / p >
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.
2026-01-25 02:47:47 +01:00
< pre > < code > import "markdown" for Markdown< / code > < / pre >
< h2 > Markdown Class< / h2 >
< div class = "class-header" >
< h3 > Markdown< / h3 >
< p > Markdown to HTML converter< / p >
< / div >
< h3 > Static Methods< / h3 >
< div class = "method-signature" >
< span class = "method-name" > Markdown.toHtml< / span > (< span class = "param" > text< / span > ) → < span class = "type" > String< / span >
< / div >
< p > Converts Markdown text to HTML.< / p >
< ul class = "param-list" >
< li > < span class = "param-name" > text< / span > < span class = "param-type" > (String)< / span > - Markdown text< / li >
< li > < span class = "returns" > Returns:< / span > HTML string< / li >
< / ul >
< pre > < code > var html = Markdown.toHtml("# Hello World")
System.print(html) // < h1> Hello World< /h1> < / code > < / pre >
< div class = "method-signature" >
< span class = "method-name" > Markdown.toHtml< / span > (< span class = "param" > text< / span > , < span class = "param" > options< / span > ) → < span class = "type" > String< / span >
< / div >
< p > Converts Markdown text to HTML with options.< / p >
< ul class = "param-list" >
< li > < span class = "param-name" > text< / span > < span class = "param-type" > (String)< / span > - Markdown text< / li >
< li > < span class = "param-name" > options< / span > < span class = "param-type" > (Map)< / span > - Conversion options< / li >
< li > < span class = "returns" > Returns:< / span > HTML string< / li >
< / ul >
< div class = "method-signature" >
< span class = "method-name" > Markdown.fromHtml< / span > (< span class = "param" > html< / span > ) → < span class = "type" > String< / span >
< / div >
< p > Converts HTML to Markdown text.< / p >
< ul class = "param-list" >
< li > < span class = "param-name" > html< / span > < span class = "param-type" > (String)< / span > - HTML string< / li >
< li > < span class = "returns" > Returns:< / span > Markdown text< / li >
< / ul >
< pre > < code > var md = Markdown.fromHtml("< h1> Hello World< /h1> ")
System.print(md) // # Hello World< / code > < / pre >
< div class = "method-signature" >
< span class = "method-name" > Markdown.fromHtml< / span > (< span class = "param" > html< / span > , < span class = "param" > options< / span > ) → < span class = "type" > String< / span >
< / div >
< p > Converts HTML to Markdown text with options.< / p >
< ul class = "param-list" >
< li > < span class = "param-name" > html< / span > < span class = "param-type" > (String)< / span > - HTML string< / li >
< li > < span class = "param-name" > options< / span > < span class = "param-type" > (Map)< / span > - Conversion options< / li >
< li > < span class = "returns" > Returns:< / span > Markdown text< / li >
< / ul >
< h2 > Options< / h2 >
< h3 > toHtml Options< / h3 >
< table >
< tr >
< th > Option< / th >
< th > Type< / th >
< th > Default< / th >
< th > Description< / th >
< / tr >
< tr >
< td > < code > safeMode< / code > < / td >
< td > Bool< / td >
< td > < code > false< / code > < / td >
< td > Escape HTML in input to prevent XSS< / td >
< / tr >
< / table >
< h3 > fromHtml Options< / h3 >
< table >
< tr >
< th > Option< / th >
< th > Type< / th >
< th > Default< / th >
< th > Description< / th >
< / tr >
< tr >
< td > < code > stripUnknown< / code > < / td >
< td > Bool< / td >
< td > < code > true< / code > < / td >
< td > Strip unknown HTML tags, keeping their content< / td >
< / tr >
< / table >
< h2 > Supported Syntax< / h2 >
< h3 > Headings< / h3 >
< pre > < code > # Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6< / code > < / pre >
< p > Converts to < code > < h1> < / code > through < code > < h6> < / code > tags.< / p >
< h3 > Emphasis< / h3 >
< pre > < code > *italic* or _italic_
**bold** or __bold__
~~strikethrough~~< / code > < / pre >
< p > Converts to < code > < em> < / code > , < code > < strong> < / code > , and < code > < del> < / code > tags.< / p >
< h3 > Code< / h3 >
< pre > < code > Inline `code` here
```
Code block
Multiple lines
2026-01-26 10:21:03 +01:00
```
```javascript
const x = 1;
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.
2026-01-25 02:47:47 +01:00
```< / code > < / pre >
2026-01-26 10:21:03 +01:00
< p > Inline code uses < code > < code> < / code > , blocks use < code > < pre> < code> < / code > . Language identifiers after the opening fence add a < code > class="language-{lang}"< / code > attribute to the code element for syntax highlighting integration.< / p >
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.
2026-01-25 02:47:47 +01:00
< h3 > Lists< / h3 >
< pre > < code > Unordered:
- Item 1
- Item 2
* Also works
+ And this
Ordered:
1. First
2. Second
3. Third< / code > < / pre >
< p > Creates < code > < ul> < / code > and < code > < ol> < / code > with < code > < li> < / code > items.< / p >
2026-01-26 10:21:03 +01:00
< h3 > Task Lists (GFM)< / h3 >
< pre > < code > - [ ] Unchecked task
- [x] Checked task
- [X] Also checked< / code > < / pre >
< p > Creates < code > < ul class="task-list"> < / code > with checkbox inputs. Checkboxes are rendered as disabled to indicate they are display-only.< / p >
< h3 > Tables (GFM)< / h3 >
< pre > < code > | Header 1 | Header 2 | Header 3 |
|----------|:--------:|---------:|
| Left | Center | Right |
| Cell | Cell | Cell |< / code > < / pre >
< p > Creates HTML tables with < code > < thead> < / code > and < code > < tbody> < / code > . Column alignment is specified in the separator row using colons: < code > :---< / code > for left, < code > :---:< / code > for center, < code > ---:< / code > for right.< / p >
< h3 > Autolinks (GFM)< / h3 >
< pre > < code > Visit https://example.com for more info.
Email me at user@example.com< / code > < / pre >
< p > Bare URLs starting with < code > http://< / code > or < code > https://< / code > and email addresses are automatically converted to clickable links.< / p >
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.
2026-01-25 02:47:47 +01:00
< h3 > Links and Images< / h3 >
< pre > < code > [Link text](https://example.com)
< / code > < / pre >
< p > Creates < code > < a href="..."> < / code > and < code > < img src="..." alt="..."> < / code > .< / p >
< h3 > Blockquotes< / h3 >
< pre > < code > > This is a quote
> Multiple lines< / code > < / pre >
< p > Creates < code > < blockquote> < / code > with < code > < p> < / code > content.< / p >
< h3 > Horizontal Rule< / h3 >
< pre > < code > ---
***
___< / code > < / pre >
< p > Creates < code > < hr> < / code > tag.< / p >
< h3 > Paragraphs< / h3 >
< p > Text separated by blank lines becomes < code > < p> < / code > elements.< / p >
< h2 > HTML to Markdown Conversions< / h2 >
< p > The < code > fromHtml< / code > method converts the following HTML elements to Markdown:< / p >
< table >
< tr >
< th > HTML< / th >
< th > Markdown< / th >
< / tr >
< tr >
< td > < code > < h1> < / code > to < code > < h6> < / code > < / td >
< td > < code > #< / code > to < code > ######< / code > < / td >
< / tr >
< tr >
< td > < code > < strong> < / code > , < code > < b> < / code > < / td >
< td > < code > **text**< / code > < / td >
< / tr >
< tr >
< td > < code > < em> < / code > , < code > < i> < / code > < / td >
< td > < code > *text*< / code > < / td >
< / tr >
< tr >
< td > < code > < code> < / code > < / td >
< td > < code > `text`< / code > < / td >
< / tr >
< tr >
< td > < code > < pre> < code> < / code > < / td >
< td > Fenced code block< / td >
< / tr >
< tr >
< td > < code > < a href="url"> < / code > < / td >
< td > < code > [text](url)< / code > < / td >
< / tr >
< tr >
< td > < code > < img src="url" alt=""> < / code > < / td >
< td > < code > < / code > < / td >
< / tr >
< tr >
< td > < code > < ul> < li> < / code > < / td >
< td > < code > - item< / code > < / td >
< / tr >
< tr >
< td > < code > < ol> < li> < / code > < / td >
< td > < code > 1. item< / code > < / td >
< / tr >
< tr >
< td > < code > < blockquote> < / code > < / td >
< td > < code > > text< / code > < / td >
< / tr >
< tr >
< td > < code > < hr> < / code > < / td >
< td > < code > ---< / code > < / td >
< / tr >
< tr >
< td > < code > < del> < / code > , < code > < s> < / code > < / td >
< td > < code > ~~text~~< / code > < / td >
< / tr >
2026-01-26 10:21:03 +01:00
< tr >
< td > < code > < table> < / code > < / td >
< td > GFM table syntax< / td >
< / tr >
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.
2026-01-25 02:47:47 +01:00
< / table >
< p > Container tags (< code > < div> < / code > , < code > < span> < / code > , < code > < section> < / code > , etc.) are stripped but their content is preserved. Script and style tags are removed entirely.< / p >
< h2 > Examples< / h2 >
< h3 > Basic Conversion< / h3 >
< pre > < code > import "markdown" for Markdown
var md = "
# Welcome
This is a **Markdown** document with:
- Lists
- *Emphasis*
- `Code`
Visit [Wren](https://wren.io) for more.
"
var html = Markdown.toHtml(md)
System.print(html)< / code > < / pre >
< h3 > Safe Mode for User Content< / h3 >
< pre > < code > import "markdown" for Markdown
var userInput = "# Title\n< script> alert('xss')< /script> \nContent here."
var safeHtml = Markdown.toHtml(userInput, {"safeMode": true})
System.print(safeHtml)< / code > < / pre >
< h3 > Rendering a Blog Post< / h3 >
< pre > < code > import "markdown" for Markdown
import "io" for File
var postContent = File.read("post.md")
var html = Markdown.toHtml(postContent)
var page = "< html>
< head> < title> Blog< /title> < /head>
< body>
< article>
%(html)
< /article>
< /body>
< /html> "
File.write("post.html", page)< / code > < / pre >
2026-01-26 10:21:03 +01:00
< h3 > Code Blocks with Language Classes< / h3 >
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.
2026-01-25 02:47:47 +01:00
< pre > < code > import "markdown" for Markdown
var md = "
```wren
System.print(\"Hello, World!\")
```
"
var html = Markdown.toHtml(md)
System.print(html)
2026-01-26 10:21:03 +01:00
// < pre> < code class="language-wren"> System.print("Hello, World!")< /code> < /pre> < / code > < / pre >
< h3 > Tables< / h3 >
< pre > < code > import "markdown" for Markdown
var md = "
| Name | Age | City |
|-------|----:|:----------|
| Alice | 30 | New York |
| Bob | 25 | London |
"
var html = Markdown.toHtml(md)
System.print(html)< / code > < / pre >
< h3 > Task Lists< / h3 >
< pre > < code > import "markdown" for Markdown
var md = "
## Project Tasks
- [x] Design database schema
- [x] Implement API endpoints
- [ ] Write unit tests
- [ ] Deploy to production
"
var html = Markdown.toHtml(md)
System.print(html)< / code > < / pre >
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.
2026-01-25 02:47:47 +01:00
< h3 > Combining with Templates< / h3 >
< pre > < code > import "markdown" for Markdown
import "jinja" for Environment, DictLoader
var env = Environment.new(DictLoader.new({
"base": "< html> < body> {{ content }}< /body> < /html> "
}))
var md = "# Hello\n\nThis is **Markdown**."
var content = Markdown.toHtml(md)
var html = env.getTemplate("base").render({"content": content})
System.print(html)< / code > < / pre >
< h3 > Converting HTML to Markdown< / h3 >
< pre > < code > import "markdown" for Markdown
var html = "
< html>
< body>
< h1> Article Title< /h1>
< p> This is < strong> important< /strong> content.< /p>
< ul>
< li> First item< /li>
< li> Second item< /li>
< /ul>
< /body>
< /html>
"
var md = Markdown.fromHtml(html)
System.print(md)
// # Article Title
//
// This is **important** content.
//
// - First item
// - Second item< / code > < / pre >
< h3 > Cleaning HTML for Plain Text< / h3 >
< pre > < code > import "markdown" for Markdown
var webContent = "< div> < script> alert('xss')< /script> < p> Safe < b> content< /b> < /p> < /div> "
var clean = Markdown.fromHtml(webContent)
System.print(clean) // Safe **content**< / code > < / pre >
< div class = "admonition warning" >
< div class = "admonition-title" > Warning< / div >
< p > When rendering user-provided Markdown, always use < code > safeMode: true< / code > to prevent cross-site scripting (XSS) attacks. Safe mode escapes HTML entities in the input text.< / p >
< / div >
< div class = "admonition note" >
< div class = "admonition-title" > Note< / div >
2026-01-26 10:21:03 +01:00
< p > Language identifiers after code fences (e.g., < code > ```wren< / code > ) are added as < code > class="language-{lang}"< / code > to the code element. This is compatible with syntax highlighters like Prism.js or highlight.js.< / p >
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.
2026-01-25 02:47:47 +01:00
< / div >
feat: add wasm build targets, profile hooks, os_demo example, and restructure manual source
- Add `wasm`, `wasm-clean`, and `install-emscripten` phony targets to Makefile for WebAssembly cross-compilation
- Insert `WREN_PROFILE_ENTER`/`WREN_PROFILE_EXIT` macros in `wren_vm.h` and `wren_vm.c` to support optional runtime profiling via `WREN_PROFILE_ENABLED`
- Create `example/os_demo.wren` demonstrating Platform, Process, and conditional exit usage
- Update `example/regex_demo.wren` to import `Match` and exercise Match object properties, groups, and `matchAll`
- Remove static HTML manual pages (`base64.html`, `dns.html`, `json.html`) and replace with structured `manual_src/` directory containing Jinja2 templates, YAML metadata, and content pages
- Expand `README.md` with build targets table, manual building instructions, source layout, and guide for adding new module documentation
2026-01-26 05:12:14 +01:00
{% endblock %}