是什么 – 不是什么?
JML(JSON-Inspired Markup Language)是一种受 JSON 结构和 DSL 启发的创新标记语言,专为 Ascoos OS 和现代 Web 设计。
其目标是提供一种轻量级、安全且易用的传统 HTML 替代方案,重点在于 AI 兼容性、去中心化(Web5)和最小化语法。
简要概述
是
不是
JML vs HTML – 2026 年对比
| 特性 | JML | HTML5 |
|---|---|---|
| 大小(Hello World 压缩版) | 64 字符 | 108 字符 |
| 含 meta + viewport | 177 字符 | 212 字符 |
| 平均减少 | 16–40% | – |
| 样板代码 | 无 | DOCTYPE、head、body... |
| XSS 安全性 | 安全(基于 AST) | 依赖开发者 |
| 可执行逻辑(宏) | 支持 | 不支持 |
| 加密支持 | 支持(WIC) | 不支持 |
| 浏览器原生支持 | 否(需扩展) | 是 |
AST – JML 的核心
JML 不是标记语言。它是带有原生 AST 的 DSL – 2030 年的标记语言,今天可用。
它支持语义宏、转换、调试以及无 XSS 的安全渲染。
AST 结构示例 – 支持验证、宏和安全渲染
立即尝试 JML
html {
head {
meta:charset('UTF-8')
link:rel('stylesheet'),href('https://cdn.ascoos.com/bootlib/css/bootlib.min.css')
}
body:class('dark-theme') {
h1{`欢迎体验 JML!`}
p{`Ascoos OS 的轻量级标记语言。`}
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.ascoos.com/bootlib/css/bootlib.min.css">
</head>
<body class="dark-theme">
<h1>欢迎体验 JML!</h1>
<p>Ascoos OS 的轻量级标记语言。</p>
</body>
</html>
JML(左侧)生成完全相同的 HTML(右侧) – 字符减少 17%。
JML Studio 和生成的辅助代码
TAG html
TAG head
TAG meta CHARSET 'UTF-8'
TAG link REL 'stylesheet' HREF 'https://cdn.ascoos.com/bootlib/css/bootlib.min.css'
TAG body CLASS 'dark-theme'
TAG h1
TEXT '欢迎体验 JML!'
TAG p
TEXT 'Ascoos OS 的轻量级标记语言。'
{
"type": "group",
"name": null,
"value": null,
"attributes": [],
"children": [
{
"type": "tag",
"name": "html",
"value": null,
"attributes": [],
"children": [
{
"type": "tag",
"name": "head",
"value": null,
"attributes": [],
"children": [
{
"type": "tag",
"name": "meta",
"value": null,
"attributes": [
{
"type": "attribute",
"name": "charset",
"value": "UTF-8",
"attributes": [],
"children": []
}
],
"children": []
},
{
"type": "tag",
"name": "link",
"value": null,
"attributes": [
{
"type": "attribute",
"name": "rel",
"value": "stylesheet",
"attributes": [],
"children": []
},
{
"type": "attribute",
"name": "href",
"value": "https://cdn.ascoos.com/bootlib/css/bootlib.min.css",
"attributes": [],
"children": []
}
],
"children": []
}
]
},
{
"type": "tag",
"name": "body",
"value": null,
"attributes": [
{
"type": "attribute",
"name": "class",
"value": "dark-theme",
"attributes": [],
"children": []
}
],
"children": [
{
"type": "tag",
"name": "h1",
"value": null,
"attributes": [],
"children": [
{
"type": "content",
"name": null,
"value": "欢迎体验 JML!",
"attributes": [],
"children": []
}
]
},
{
"type": "tag",
"name": "p",
"value": null,
"attributes": [],
"children": [
{
"type": "content",
"name": null,
"value": "Ascoos OS 的轻量级标记语言。",
"attributes": [],
"children": []
}
]
}
]
}
]
}
]
}
两种生成格式,DSL(左侧)和 AST(右侧),均结构化以用于 WebAI。
服务器端渲染
<?php
/**
* @ASCOOS-NAME : Ascoos OS
* @ASCOOS-VERSION : 26.0.0
* @ASCOOS-SUPPORT : support@ascoos.com
* @ASCOOS-BUGS : https://issues.ascoos.com
*
* @CASE-STUDY : jml_to_html_renderer.php
* @fileNo : ASCOOS-OS-CASESTUDY-SEC00268
*
* @desc Parses JML syntax into HTML using THTML, generates full page from nested structure.
*
* @since PHP 8.2.0
*/
declare(strict_types=1);
use ASCOOS\OS\Kernel\HTML\THTML;
use ASCOOS\OS\Kernel\Files\TFilesHandler;
$properties = [
'output' => './generated_page.html'
];
try {
$html = new THTML();
$files = new TFilesHandler();
// JML as string.
$jmlString = <<<'JML'
html:lang('en') {
head {
meta:charset('UTF-8')
meta:name('viewport'),content('width=device-width, initial-scale=1.0')
title {`Advanced Sample Page`}
style {
`.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: #f4f4f4;
}
.header {
text-align: center;
color: #333;
padding: 10px;
border-bottom: 2px solid #000;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
font-weight: bold;
}
.form-group input, .form-group select {
width: 100%;
padding: 8px;
margin-top: 5px;
}`
}
script {
`function validateForm() {
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
if (name === "" || email === "") {
alert("Please fill out all fields!");
return false;
}
return true;
}`
}
}
body {
div:class('container') {
div:class('header') {
h1 {`Welcome to Ascoos OS Demo`}
p {`This is a complex demo with nested elements and interactivity.`}
}
div:class('content') {
h2 {`User Registration`}
form:onsubmit('return validateForm()'),method('POST'),action('/submit') {
div:class('form-group') {
label:for('name') {`Name:`}
input:type('text'),id('name'),name('name'),required('')
}
div:class('form-group') {
label:for('email') {`Email:`}
input:type('email'),id('email'),name('email'),required('')
}
div:class('form-group') {
label:for('country') {`Country:`}
select:id('country'),name('country') {
option:value('us') {`United States`}
option:value('gr') {`Greece`}
option:value('de') {`Germany`}
}
}
button:type('submit') {`Submit`}
}
br
div:class('footer') {
p {`© 2025 Ascoos OS. All rights reserved.`}
br
a:href('https://ascoos.com') {`Visit our site`}
}
}
}
}
}
JML;
$fullHtml = $html->fromJMLString($jmlString);
$output = '' . $fullHtml;
$files->writeToFileWithCheck($output, $properties['output']);
echo "JML Parsed! Generated HTML:\n";
echo $output . "\n";
echo "Saved to: " . $properties['output'] . "\n";
$html->Free();
$files->Free();
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>
使用 PHP 渲染器,可即时生成 HTML,用于动态站点,无需样板代码。
Ascoos JML Renderer – 浏览器扩展
安装这款轻量级扩展,即可将任意网页变为 JML 就绪:客户端渲染,无任何依赖!
完整 JML 文档
渲染 <script type="text/jml"> 为完整 HTML 文档。
内联 JML 块
在现有 HTML 中嵌入 <jml> ... </jml>。
支持空标签和嵌套
br、hr、img、input + 嵌套块、属性、多行文本。
纯 JS – 无依赖
适用于任何页面(本地/远程),兼容 Manifest V3。
该扩展体积小(26 KB),不收集数据,即装即用 – 非常适合希望无需配置即可实验 JML 的开发者。
路线图
常见问题
JML 是否兼容现有浏览器?
是的,通过渲染器生成干净的 HTML5。无需更改浏览器。
JML 如何处理脚本和样式?
支持内联脚本/样式和外部链接,具有原生转义以确保安全。
能否与 React 等框架一起使用?
可以,通过 JML → JSX 转换或直接解析为自定义组件。