sommark 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -4
- package/core/evaluator.js +408 -132
- package/core/helpers/config-loader.js +8 -8
- package/core/helpers/lib.js +1 -4
- package/core/helpers/preprocessor.js +23 -6
- package/core/helpers/url.js +12 -0
- package/core/modules.js +16 -14
- package/core/transpiler.js +23 -19
- package/dist/assets/emscripten-module-B1g2L2eS.wasm +0 -0
- package/dist/assets/emscripten-module-DHbYPfAp.wasm +0 -0
- package/dist/assets/emscripten-module-ZrHFMo7O.wasm +0 -0
- package/dist/assets/emscripten-module-uFzwHH0Y.wasm +0 -0
- package/dist/emscripten-module.browser-LGpDp2J2.js +24 -0
- package/dist/ffi-7DRR-T-4.js +3 -0
- package/dist/module-ES6BEMUI-SZ556_bi.js +10 -0
- package/dist/sommark.browser.js +14532 -0
- package/helpers/fetch-fs.js +37 -0
- package/helpers/spinner.js +7 -1
- package/helpers/virtual-fs.js +29 -0
- package/index.browser.js +87 -0
- package/index.js +23 -419
- package/index.shared.js +443 -0
- package/package.json +16 -5
package/README.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# SomMark <img src="assets/smark.logo.png" width="80" align="right">
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/sommark)
|
|
4
|
+
[](https://www.npmjs.com/package/sommark)
|
|
5
|
+
[](https://nodejs.org)
|
|
4
6
|
[](https://github.com/Adam-Elmi/SomMark/blob/master/LICENSE)
|
|
5
7
|
|
|
6
8
|
SomMark is a high-performance markup language designed for structured content. It acts as an extensible source language that can be transformed into multiple formats like HTML, JSON, MDX, XML, and Markdown.
|
|
7
9
|
|
|
8
10
|
SomMark uses explicit structural boundaries to ensure your document remains stable and predictable. It enables infinite nesting and provides total control over your contents.
|
|
9
11
|
|
|
12
|
+
> **v4.2.0 — Browser Support**: SomMark now compiles templates directly in the browser with no Node.js dependencies. Use the `sommark/browser` entry point with any bundler (Vite, Webpack, Rollup, esbuild). See [Browser API docs](docs/api/Browser/) for `resolveBaseDir` and `renderCompiledHTML`.
|
|
13
|
+
|
|
10
14
|
---
|
|
11
15
|
|
|
12
16
|
## Install
|
|
@@ -79,19 +83,28 @@ Pass metadata (called **Props**, similar to component properties in React/Vue) t
|
|
|
79
83
|
* **Inline Elements**: Passed after `=` or `:` inside the identifier parenthesis (e.g., `(text)->(link = "url")`).
|
|
80
84
|
* **At-Blocks**: Passed after `:` and terminated with `;` (e.g., `@_code: lang: "js";`).
|
|
81
85
|
|
|
86
|
+
**Blocks** — props come after `=`, separated by commas. Positional args have no key; named args use `key: value`.
|
|
82
87
|
```ini
|
|
83
|
-
# Blocks (using '=')
|
|
84
88
|
[div = "container", class: "flex"][end]
|
|
89
|
+
# ↑ positional ↑ named
|
|
90
|
+
```
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
**Inline Elements** — same prop syntax, after `=` or `:` inside the identifier.
|
|
93
|
+
```ini
|
|
87
94
|
(Visit Website)->(link = "https://sommark.org", target: "_blank")
|
|
95
|
+
# ↑ positional url ↑ named prop
|
|
96
|
+
```
|
|
88
97
|
|
|
89
|
-
|
|
98
|
+
**At-Blocks** — props follow `:` on the opening line and are terminated with `;`. The body is captured as raw text.
|
|
99
|
+
```ini
|
|
90
100
|
@_code: lang: "js", active: js{true}, user: v{userId};
|
|
101
|
+
# ↑ string ↑ native JS value ↑ local variable
|
|
91
102
|
console.log("Hello World");
|
|
92
103
|
@_end_@
|
|
104
|
+
```
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
**Static logic as a prop value** — any prop value can be a compile-time expression.
|
|
107
|
+
```ini
|
|
95
108
|
[Date = year: static ${ new Date().getFullYear() }$][end]
|
|
96
109
|
```
|
|
97
110
|
|
|
@@ -225,6 +238,7 @@ sommark -h Show help
|
|
|
225
238
|
|
|
226
239
|
## Programmatic Usage
|
|
227
240
|
|
|
241
|
+
**Node.js**
|
|
228
242
|
```js
|
|
229
243
|
import SomMark from "sommark";
|
|
230
244
|
|
|
@@ -237,6 +251,21 @@ const output = await engine.transpile();
|
|
|
237
251
|
// <h1>Hello World</h1>
|
|
238
252
|
```
|
|
239
253
|
|
|
254
|
+
**Browser** (v4.2.0+)
|
|
255
|
+
```js
|
|
256
|
+
import SomMark, { resolveBaseDir, renderCompiledHTML } from "sommark/browser";
|
|
257
|
+
|
|
258
|
+
const src = await fetch("./main.smark").then(r => r.text());
|
|
259
|
+
|
|
260
|
+
const engine = new SomMark({
|
|
261
|
+
src,
|
|
262
|
+
format: "html",
|
|
263
|
+
baseDir: resolveBaseDir("./templates/"), // resolves imports via fetch
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
renderCompiledHTML(document.getElementById("output"), await engine.transpile());
|
|
267
|
+
```
|
|
268
|
+
|
|
240
269
|
---
|
|
241
270
|
|
|
242
271
|
## Configuration
|
|
@@ -322,6 +351,7 @@ Full reference in [`docs/api/Mapper`](docs/api/Mapper).
|
|
|
322
351
|
|------------------|-----------------------------------------------|
|
|
323
352
|
| Syntax Reference | [`docs/syntax/`](docs/syntax) |
|
|
324
353
|
| Core API | [`docs/api/Core/`](docs/api/Core) |
|
|
354
|
+
| Browser API | [`docs/api/Browser/`](docs/api/Browser) |
|
|
325
355
|
| Mapper API | [`docs/api/Mapper/`](docs/api/Mapper) |
|
|
326
356
|
| Sandbox API | [`docs/api/Sandbox/`](docs/api/Sandbox) |
|
|
327
357
|
| Output Formats | [`docs/languages/`](docs/languages) |
|