thoth-markup-lang 1.0.2 → 4.1.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/.htaccess +9 -0
- package/README.md +30 -9
- package/engine.php +138 -0
- package/package.json +35 -5
- package/thoth.js +142 -94
- package/index.html +0 -22
- package/index.thoth +0 -13
- package/test.html +0 -76
- package/test.thoth +0 -67
package/.htaccess
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# THOTH Server Configuration
|
|
2
|
+
RewriteEngine On
|
|
3
|
+
|
|
4
|
+
# توجيه أي طلب لملف ينتهي بـ .thoth إلى محرك المهندس عبد الفتاح
|
|
5
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
6
|
+
RewriteRule ^(.*)\.thoth$ engine.php?file=$1.thoth [L,QSA]
|
|
7
|
+
|
|
8
|
+
# جعل index.thoth هو الملف الرئيسي للموقع
|
|
9
|
+
DirectoryIndex index.thoth
|
package/README.md
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# <p align="center">𓅓 THOTH: The Pure Dynasty Edition</p>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://img.shields.io/npm/v/thoth-markup-lang?style=for-the-badge&color=D4AF37&logo=npm" alt="NPM Version" />
|
|
5
|
+
<img src="https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge" alt="Maintained" />
|
|
6
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="License" />
|
|
7
|
+
<img src="https://img.shields.io/badge/Built%20In-Egypt%20🇪🇬-orange?style=for-the-badge" alt="Egypt" />
|
|
8
|
+
</p>
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
<p align="center">
|
|
11
|
+
<strong>The Pythonic Architect of the Web.</strong><br />
|
|
12
|
+
Write clean, indentation-based markup that compiles instantly into standard HTML5. <br />
|
|
13
|
+
Stop writing brackets. Start writing wisdom.
|
|
14
|
+
</p>
|
|
7
15
|
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🏛️ What is THOTH?
|
|
19
|
+
|
|
20
|
+
**THOTH** is a revolutionary markup engine that eliminates the clutter of traditional HTML. By adopting a **Python-like indentation system**, it allows developers to build complex web structures with absolute visual clarity.
|
|
21
|
+
|
|
22
|
+
Named after the Egyptian God of Wisdom and Writing, THOTH v3.0 represents a new era where the developer only cares about the structure, leaving the messy `< >` brackets behind.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## ✨ Key Features
|
|
10
27
|
|
|
11
|
-
|
|
12
|
-
|
|
28
|
+
* **💎 Zero-Bracket Architecture:** No more opening or closing tags.
|
|
29
|
+
* **🐍 Pythonic Logic:** Structure is defined by indentation (spaces/tabs).
|
|
30
|
+
* **⚡ High-Performance Compiler:** Blazing fast compilation from `.thoth` to `.html`.
|
|
31
|
+
* **💉 Raw Code Injection:** Native blocks for `StyleSheet` (CSS) and `Scripting` (JS).
|
|
32
|
+
* **🌍 Universal Runtime:** Run `.thoth` files directly on your server via the THOTH Server Engine.
|
|
33
|
+
* **🛡️ HTML5 Semantic Purity:** 100% support for all modern HTML5 tags and attributes.
|
|
13
34
|
|
|
14
35
|
---
|
|
15
36
|
|
|
16
37
|
## 🚀 Installation
|
|
17
38
|
|
|
18
|
-
Install THOTH globally
|
|
39
|
+
Install the THOTH CLI globally via NPM:
|
|
19
40
|
|
|
20
41
|
```bash
|
|
21
42
|
npm install -g thoth-markup-lang
|
package/engine.php
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* THOTH Sovereign Runtime Engine v7.0
|
|
4
|
+
* Developed by: Engineer Abdelfatah Abdelhamed 🇪🇬
|
|
5
|
+
* * هذا المحرك يقوم بتشغيل ملفات .thoth مباشرة كبيئة مستقلة.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
class ThothEngine {
|
|
9
|
+
private $tagMap = [
|
|
10
|
+
'Title' => 'h1', 'Sub' => 'h2', 'Heading' => 'h3', 'Text' => 'p',
|
|
11
|
+
'Box' => 'div', 'Container' => 'section', 'Nav' => 'nav',
|
|
12
|
+
'Header' => 'header', 'Footer' => 'footer', 'Bold' => 'strong',
|
|
13
|
+
'Italic' => 'em', 'Link' => 'a', 'Image' => 'img', 'List' => 'ul',
|
|
14
|
+
'Item' => 'li', 'Button' => 'button', 'Input' => 'input',
|
|
15
|
+
'Break' => 'br', 'Line' => 'hr'
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
private $voidTags = ['img', 'br', 'hr', 'input', 'meta', 'link'];
|
|
19
|
+
|
|
20
|
+
public function render($filePath) {
|
|
21
|
+
if (!file_exists($filePath)) {
|
|
22
|
+
header("HTTP/1.0 404 Not Found");
|
|
23
|
+
return "<h1 style='font-family:sans-serif; text-align:center; margin-top:20%'>404 | THOTH File Not Found</h1>";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
$code = file_get_contents($filePath);
|
|
27
|
+
$lines = explode("\n", $code);
|
|
28
|
+
|
|
29
|
+
$htmlBody = "";
|
|
30
|
+
$stack = [];
|
|
31
|
+
$inRawMode = false;
|
|
32
|
+
$rawType = '';
|
|
33
|
+
$rawIndent = 0;
|
|
34
|
+
|
|
35
|
+
foreach ($lines as $line) {
|
|
36
|
+
$trimmed = trim($line);
|
|
37
|
+
|
|
38
|
+
// 1. تجاهل الأسطر الفارغة والتعليقات (تم حل مشكلة ظهور الكومنت)
|
|
39
|
+
if ($trimmed === "" || strpos($trimmed, '#') === 0) continue;
|
|
40
|
+
|
|
41
|
+
$indent = strlen($line) - strlen(ltrim($line));
|
|
42
|
+
|
|
43
|
+
// 2. معالجة الـ Raw Mode (StyleSheet / Scripting)
|
|
44
|
+
if ($inRawMode) {
|
|
45
|
+
if ($indent <= $rawIndent && !empty($trimmed)) {
|
|
46
|
+
$inRawMode = false;
|
|
47
|
+
$htmlBody .= "</$rawType>\n";
|
|
48
|
+
} else {
|
|
49
|
+
$htmlBody .= $line . "\n";
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 3. تحليل السطر وفصل الأوامر عن المحتوى
|
|
55
|
+
// نستخدم خوارزمية البحث عن أول ":" خارج علامات التنصيص
|
|
56
|
+
$sep = -1;
|
|
57
|
+
$inQuotes = false;
|
|
58
|
+
for ($i = 0; $i < strlen($trimmed); $i++) {
|
|
59
|
+
if ($trimmed[$i] === '"') $inQuotes = !$inQuotes;
|
|
60
|
+
if ($trimmed[$i] === ':' && !$inQuotes) {
|
|
61
|
+
$sep = $i;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if ($sep !== -1) {
|
|
67
|
+
$cmdPart = trim(substr($trimmed, 0, $sep));
|
|
68
|
+
$val = trim(substr($trimmed, $sep + 1));
|
|
69
|
+
} else {
|
|
70
|
+
$cmdPart = $trimmed;
|
|
71
|
+
$val = "";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// فصل اسم التاج عن الخصائص (Attributes)
|
|
75
|
+
$spacePos = strpos($cmdPart, ' ');
|
|
76
|
+
if ($spacePos !== false) {
|
|
77
|
+
$cmd = substr($cmdPart, 0, $spacePos);
|
|
78
|
+
$attrs = trim(substr($cmdPart, $spacePos));
|
|
79
|
+
} else {
|
|
80
|
+
$cmd = $cmdPart;
|
|
81
|
+
$attrs = "";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 4. الدخول في الـ Raw Mode للأكواد المدمجة
|
|
85
|
+
if ($cmd === "StyleSheet" || $cmd === "Scripting") {
|
|
86
|
+
$inRawMode = true;
|
|
87
|
+
$rawType = ($cmd === "StyleSheet") ? "style" : "script";
|
|
88
|
+
$rawIndent = $indent;
|
|
89
|
+
$htmlBody .= "<$rawType>\n";
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 5. إغلاق التاجات السابقة بناءً على مستوى المسافات
|
|
94
|
+
while (count($stack) > 0 && $stack[count($stack) - 1]['indent'] >= $indent) {
|
|
95
|
+
$closedTag = array_pop($stack);
|
|
96
|
+
$htmlBody .= "</" . $closedTag['tag'] . ">\n";
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
$tag = isset($this->tagMap[$cmd]) ? $this->tagMap[$cmd] : strtolower($cmd);
|
|
100
|
+
$openingTag = "<$tag" . ($attrs ? " $attrs" : "") . ">";
|
|
101
|
+
|
|
102
|
+
// 6. بناء هيكل الـ HTML النهائي
|
|
103
|
+
if (in_array($tag, $this->voidTags)) {
|
|
104
|
+
$htmlBody .= str_repeat(" ", $indent) . $openingTag . "\n";
|
|
105
|
+
} elseif ($val !== "") {
|
|
106
|
+
$htmlBody .= str_repeat(" ", $indent) . $openingTag . $val . "</$tag>\n";
|
|
107
|
+
} else {
|
|
108
|
+
$htmlBody .= str_repeat(" ", $indent) . $openingTag . "\n";
|
|
109
|
+
$stack[] = ['tag' => $tag, 'indent' => $indent];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// إغلاق أي تاجات متبقية في نهاية الملف
|
|
114
|
+
while ($closedTag = array_pop($stack)) {
|
|
115
|
+
$htmlBody .= "</" . $closedTag['tag'] . ">\n";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return $this->generateFullHTML($htmlBody);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private function generateFullHTML($body) {
|
|
122
|
+
// بناء الهيكل النهائي المتوافق مع محركات البحث (SEO)
|
|
123
|
+
return "<!DOCTYPE html>\n<html lang='ar' dir='rtl'>\n<head>\n" .
|
|
124
|
+
" <meta charset='UTF-8'>\n" .
|
|
125
|
+
" <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n" .
|
|
126
|
+
" <meta name='generator' content='THOTH Sovereign Engine 7.0'>\n" .
|
|
127
|
+
" <meta name='author' content='Abdelfatah Abdelhamed'>\n" .
|
|
128
|
+
"</head>\n<body>\n$body\n</body>\n</html>";
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// تشغيل المحرك ومعالجة الطلبات
|
|
133
|
+
$engine = new ThothEngine();
|
|
134
|
+
$fileRequested = isset($_GET['file']) ? $_GET['file'] : 'index.thoth';
|
|
135
|
+
|
|
136
|
+
// منع الوصول لملفات خارج النظام للأمان
|
|
137
|
+
$safeFile = basename($fileRequested);
|
|
138
|
+
echo $engine->render($safeFile);
|
package/package.json
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thoth-markup-lang",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
|
+
"description": "THOTH is a sovereign, high-performance indentation-based markup language and runtime engine. Built by Engineer Abdelfatah Abdelhamed to redefine web architecture with pure, bracket-less logic and 100% HTML5 semantic compliance.",
|
|
5
5
|
"main": "thoth.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"thoth": "./thoth.js"
|
|
8
8
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node thoth.js",
|
|
11
|
+
"build": "thoth"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"thoth",
|
|
15
|
+
"thoth-lang",
|
|
16
|
+
"thoth-runtime",
|
|
17
|
+
"markup-language",
|
|
18
|
+
"indentation-based",
|
|
19
|
+
"pythonic-markup",
|
|
20
|
+
"clean-code-web",
|
|
21
|
+
"sovereign-engine",
|
|
22
|
+
"pure-markup",
|
|
23
|
+
"egyptian-engineering",
|
|
24
|
+
"abdelfatah-abdelhamed",
|
|
25
|
+
"zero-brackets",
|
|
26
|
+
"web-architect",
|
|
27
|
+
"performance-markup",
|
|
28
|
+
"minimalist-code",
|
|
29
|
+
"html5-generator",
|
|
30
|
+
"smart-indent",
|
|
31
|
+
"native-thoth"
|
|
32
|
+
],
|
|
33
|
+
"author": "Abdelfatah Abdelhamed <abdelfatahabdelhamed.kfs@gmail.com>",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=14.0.0"
|
|
37
|
+
},
|
|
38
|
+
"preferGlobal": true,
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
12
42
|
}
|
package/thoth.js
CHANGED
|
@@ -1,111 +1,159 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* THOTH Engine v4.1.0 - "The Sovereign Architect"
|
|
5
|
+
* Developed by: Engineer Abdelfatah Abdelhamed 🇪🇬
|
|
6
|
+
* --------------------------------------------------
|
|
7
|
+
* Pure Indentation-Based Markup Language & Runtime
|
|
8
|
+
*/
|
|
9
|
+
|
|
3
10
|
const fs = require('fs');
|
|
4
11
|
const path = require('path');
|
|
5
12
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const command = process.argv[2];
|
|
14
|
+
const file = process.argv[3];
|
|
15
|
+
|
|
16
|
+
// تنسيق رسالة الاستخدام في حالة الخطأ
|
|
17
|
+
if (!command || (command !== 'build' && !command.endsWith('.thoth'))) {
|
|
18
|
+
console.log('\x1b[33m%s\x1b[0m', '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
19
|
+
console.log('\x1b[1m\x1b[32m 𓅓 THOTH ENGINE v4.1.0 \x1b[0m');
|
|
20
|
+
console.log('\x1b[33m%s\x1b[0m', ' Developed by Engineer Abdelfatah Abdelhamed');
|
|
21
|
+
console.log('\x1b[33m%s\x1b[0m', '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
22
|
+
console.log(' Usage:');
|
|
23
|
+
console.log(' thoth build file.thoth \x1b[90m(Create a standalone HTML5 file)\x1b[0m');
|
|
24
|
+
console.log(' thoth file.thoth \x1b[90m(Fast Internal Compilation)\x1b[0m');
|
|
11
25
|
process.exit(1);
|
|
12
26
|
}
|
|
13
27
|
|
|
14
|
-
const
|
|
15
|
-
'Title': 'h1', 'Sub': 'h2', 'Text': 'p', 'Bold': 'strong', 'Italic': 'em',
|
|
16
|
-
'Box': 'div', 'Link': 'a', 'Image': 'img', 'List': 'ul', 'OrderedList': 'ol',
|
|
17
|
-
'Item': 'li', 'Row': 'tr', 'Head': 'th', 'Data': 'td', 'Line': 'hr', 'Break': 'br',
|
|
18
|
-
// الأوامر الجديدة لربط الملفات الخارجية بسرعة
|
|
19
|
-
'IncludeCss': 'link',
|
|
20
|
-
'IncludeJs': 'script'
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const voidTags = ['img', 'br', 'hr', 'input', 'meta', 'link', 'source'];
|
|
24
|
-
|
|
25
|
-
const code = fs.readFileSync(inputFile, 'utf8');
|
|
26
|
-
const lines = code.split('\n');
|
|
27
|
-
|
|
28
|
-
let html = `<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>THOTH Web App</title>\n</head>\n<body>\n`;
|
|
29
|
-
let stack = [];
|
|
30
|
-
|
|
31
|
-
// متغيرات نظام (Raw Mode) للأكواد الداخلية
|
|
32
|
-
let inRawMode = false;
|
|
33
|
-
let rawIndentLevel = 0;
|
|
34
|
-
let rawTagName = '';
|
|
35
|
-
|
|
36
|
-
lines.forEach(line => {
|
|
37
|
-
if (line.trim() === '') return;
|
|
38
|
-
|
|
39
|
-
const indent = line.search(/\S/);
|
|
40
|
-
const contentRaw = line.trim();
|
|
41
|
-
|
|
42
|
-
// لو إحنا جوه كود CSS أو JS والمسافات رجعت لورا، نقفل التاج
|
|
43
|
-
if (inRawMode && indent <= rawIndentLevel) {
|
|
44
|
-
inRawMode = false;
|
|
45
|
-
html += ' '.repeat(rawIndentLevel) + `</${rawTagName}>\n`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// لو إحنا جوه كود CSS أو JS، اطبع السطر زي ما هو من غير تعديل
|
|
49
|
-
if (inRawMode) {
|
|
50
|
-
html += line + '\n';
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const match = contentRaw.match(/^([A-Za-z0-9]+)([^:]*):?(.*)$/);
|
|
55
|
-
if (!match) return;
|
|
56
|
-
|
|
57
|
-
let command = match[1].trim();
|
|
58
|
-
let attributes = match[2].trim();
|
|
59
|
-
let content = match[3].trim();
|
|
28
|
+
const targetFile = command === 'build' ? file : command;
|
|
60
29
|
|
|
61
|
-
|
|
30
|
+
// القاموس الهندسي الشامل لجميع وسوم HTML5
|
|
31
|
+
const MAP = {
|
|
32
|
+
'Title': 'h1', 'Sub': 'h2', 'Heading': 'h3', 'Text': 'p', 'Bold': 'strong',
|
|
33
|
+
'Italic': 'em', 'Box': 'div', 'Container': 'section', 'Nav': 'nav',
|
|
34
|
+
'Header': 'header', 'Footer': 'footer', 'Article': 'article', 'Aside': 'aside',
|
|
35
|
+
'Link': 'a', 'Image': 'img', 'Button': 'button', 'List': 'ul', 'Item': 'li',
|
|
36
|
+
'Input': 'input', 'Form': 'form', 'Label': 'label', 'Break': 'br', 'Line': 'hr'
|
|
37
|
+
};
|
|
62
38
|
|
|
63
|
-
|
|
64
|
-
html += ' '.repeat(stack[stack.length - 1].indent) + `</${stack.pop().name}>\n`;
|
|
65
|
-
}
|
|
39
|
+
const VOID_TAGS = ['img', 'br', 'hr', 'input', 'meta', 'link'];
|
|
66
40
|
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
if (command === 'IncludeJs') {
|
|
73
|
-
html += ' '.repeat(indent) + `<script src="${content}"></script>\n`;
|
|
74
|
-
return;
|
|
41
|
+
function compile(filePath) {
|
|
42
|
+
if (!fs.existsSync(filePath)) {
|
|
43
|
+
console.error('\x1b[31m%s\x1b[0m', `❌ Error: File "${filePath}" not found.`);
|
|
44
|
+
process.exit(1);
|
|
75
45
|
}
|
|
76
46
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
47
|
+
const code = fs.readFileSync(filePath, 'utf8');
|
|
48
|
+
const lines = code.split(/\r?\n/);
|
|
49
|
+
let htmlBody = "";
|
|
50
|
+
let stack = [];
|
|
51
|
+
let inRaw = false, rawType = '', rawIndent = 0;
|
|
52
|
+
|
|
53
|
+
lines.forEach(line => {
|
|
54
|
+
const trimmed = line.trim();
|
|
55
|
+
|
|
56
|
+
// 1. تجاهل الأسطر الفارغة والتعليقات تماماً
|
|
57
|
+
if (!trimmed || trimmed.startsWith('#')) return;
|
|
58
|
+
|
|
59
|
+
const indent = line.search(/\S/);
|
|
60
|
+
|
|
61
|
+
// 2. نظام الـ Raw Mode للأكواد المدمجة (CSS/JS)
|
|
62
|
+
if (inRaw) {
|
|
63
|
+
if (indent <= rawIndent && trimmed !== "") {
|
|
64
|
+
inRaw = false;
|
|
65
|
+
htmlBody += `</${rawType}>\n`;
|
|
66
|
+
} else {
|
|
67
|
+
htmlBody += line + '\n';
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 3. خوارزمية الفصل الذكية (لحل مشكلة النقطتين داخل الـ Styles)
|
|
73
|
+
let sepIndex = -1;
|
|
74
|
+
let inQuotes = false;
|
|
75
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
76
|
+
if (trimmed[i] === '"') inQuotes = !inQuotes;
|
|
77
|
+
if (trimmed[i] === ':' && !inQuotes) {
|
|
78
|
+
sepIndex = i;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let cmdPart, val;
|
|
84
|
+
if (sepIndex !== -1) {
|
|
85
|
+
cmdPart = trimmed.substring(0, sepIndex).trim();
|
|
86
|
+
val = trimmed.substring(sepIndex + 1).trim();
|
|
87
|
+
} else {
|
|
88
|
+
cmdPart = trimmed;
|
|
89
|
+
val = "";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// فصل اسم التاج عن الخصائص (Attributes)
|
|
93
|
+
const spacePos = cmdPart.indexOf(' ');
|
|
94
|
+
let cmd = spacePos !== -1 ? cmdPart.substring(0, spacePos) : cmdPart;
|
|
95
|
+
let attrs = spacePos !== -1 ? cmdPart.substring(spacePos).trim() : "";
|
|
96
|
+
|
|
97
|
+
// 4. الدخول في الـ Raw Mode
|
|
98
|
+
if (cmd === "StyleSheet" || cmd === "Scripting") {
|
|
99
|
+
inRaw = true;
|
|
100
|
+
rawType = (cmd === "StyleSheet") ? "style" : "script";
|
|
101
|
+
rawIndent = indent;
|
|
102
|
+
htmlBody += `<${rawType}>\n`;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 5. إدارة قفل التاجات حسب مستوى المسافات
|
|
107
|
+
while (stack.length > 0 && stack[stack.length - 1].indent >= indent) {
|
|
108
|
+
htmlBody += `</${stack.pop().name}>\n`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let tag = MAP[cmd] || cmd.toLowerCase();
|
|
112
|
+
let openTag = `<${tag}${attrs ? ' ' + attrs : ''}>`;
|
|
113
|
+
|
|
114
|
+
if (VOID_TAGS.includes(tag)) {
|
|
115
|
+
htmlBody += openTag + '\n';
|
|
116
|
+
} else if (val) {
|
|
117
|
+
htmlBody += `${openTag}${val}</${tag}>\n`;
|
|
118
|
+
} else {
|
|
119
|
+
htmlBody += openTag + '\n';
|
|
120
|
+
stack.push({ name: tag, indent: indent });
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// إغلاق أي تاجات متبقية
|
|
125
|
+
while (stack.length > 0) {
|
|
126
|
+
htmlBody += `</${stack.pop().name}>\n`;
|
|
95
127
|
}
|
|
96
|
-
});
|
|
97
128
|
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
129
|
+
// بناء الهيكل النهائي مع تحسينات SEO
|
|
130
|
+
return `<!DOCTYPE html>
|
|
131
|
+
<html lang="ar" dir="rtl">
|
|
132
|
+
<head>
|
|
133
|
+
<meta charset="UTF-8">
|
|
134
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
135
|
+
<meta name="generator" content="THOTH Sovereign Engine v4.1.0">
|
|
136
|
+
<meta name="author" content="Abdelfatah Abdelhamed">
|
|
137
|
+
<title>Compiled by THOTH</title>
|
|
138
|
+
</head>
|
|
139
|
+
<body>
|
|
140
|
+
${htmlBody}
|
|
141
|
+
</body>
|
|
142
|
+
</html>`;
|
|
104
143
|
}
|
|
105
144
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
145
|
+
// تنفيذ عملية التجميع
|
|
146
|
+
try {
|
|
147
|
+
const result = compile(targetFile);
|
|
148
|
+
const output = targetFile.replace('.thoth', '.html');
|
|
149
|
+
fs.writeFileSync(output, result);
|
|
150
|
+
|
|
151
|
+
console.log('\x1b[32m%s\x1b[0m', `──────────────────────────────────────────`);
|
|
152
|
+
console.log('\x1b[1m\x1b[32m ✔ SUCCESS: \x1b[0m THOTH Engine has spoken.');
|
|
153
|
+
console.log('\x1b[37m Output:\x1b[0m', output);
|
|
154
|
+
console.log('\x1b[37m Author:\x1b[0m Engineer Abdelfatah Abdelhamed 🇪🇬');
|
|
155
|
+
console.log('\x1b[32m%s\x1b[0m', `──────────────────────────────────────────`);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
console.error('\x1b[31m%s\x1b[0m', `❌ Compilation Error: ${err.message}`);
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
package/index.html
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>THOTH Output</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1 style="color>#d4af37; text-align: center;": Welcome to THOTH</h1>
|
|
10
|
-
<p>This is a clean alternative to HTML.</p>
|
|
11
|
-
<div class="container">
|
|
12
|
-
<h2>Why use it?</h2>
|
|
13
|
-
<ul>
|
|
14
|
-
<li>No closing tags</li>
|
|
15
|
-
<li>Pythonic indentation</li>
|
|
16
|
-
<li>Full HTML support</li>
|
|
17
|
-
</ul>
|
|
18
|
-
<br>
|
|
19
|
-
<button onclick="alert('Hello!')">Click Me</button>
|
|
20
|
-
</div>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
package/index.thoth
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Title style="color: #d4af37; text-align: center;": Welcome to THOTH
|
|
2
|
-
Text: This is a clean alternative to HTML.
|
|
3
|
-
|
|
4
|
-
Box class="container":
|
|
5
|
-
Sub: Why use it?
|
|
6
|
-
List:
|
|
7
|
-
Item: No closing tags
|
|
8
|
-
Item: Pythonic indentation
|
|
9
|
-
Item: Full HTML support
|
|
10
|
-
|
|
11
|
-
Break:
|
|
12
|
-
|
|
13
|
-
Button onclick="alert('Hello!')": Click Me
|
package/test.html
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>THOTH Web App</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1 style="color>#d4af37; text-align: center;": Welcome to THOTH V2</h1>
|
|
10
|
-
<p>Now supporting EVERY HTML element with attributes!</p>
|
|
11
|
-
<div style="border>2px dashed #d4af37; padding: 20px; border-radius: 8px;":</div>
|
|
12
|
-
<h2>1. Full Form Support</h2>
|
|
13
|
-
<form>
|
|
14
|
-
<label>Enter your Name:</label>
|
|
15
|
-
<input type="text" placeholder="John Doe">
|
|
16
|
-
<br>
|
|
17
|
-
<label>Choose an option:</label>
|
|
18
|
-
<select>
|
|
19
|
-
<option value="1">Option A</option>
|
|
20
|
-
<option value="2">Option B</option>
|
|
21
|
-
</select>
|
|
22
|
-
<br>
|
|
23
|
-
<button type="button">Submit Data</button>
|
|
24
|
-
</form>
|
|
25
|
-
<hr>
|
|
26
|
-
<h2>2. Tables and Data</h2>
|
|
27
|
-
<table>
|
|
28
|
-
<tr>
|
|
29
|
-
<th>ID</th>
|
|
30
|
-
<th>Name</th>
|
|
31
|
-
<th>Role</th>
|
|
32
|
-
</tr>
|
|
33
|
-
<tr>
|
|
34
|
-
<td>1</td>
|
|
35
|
-
<td>Thoth</td>
|
|
36
|
-
<td>Scribe</td>
|
|
37
|
-
</tr>
|
|
38
|
-
<tr>
|
|
39
|
-
<td>2</td>
|
|
40
|
-
<td>Horus</td>
|
|
41
|
-
<td>Guardian</td>
|
|
42
|
-
</tr>
|
|
43
|
-
</table>
|
|
44
|
-
<hr>
|
|
45
|
-
<h2>3. Lists</h2>
|
|
46
|
-
<ol>
|
|
47
|
-
<li>Clean Syntax</li>
|
|
48
|
-
<li>Python-like Indentation</li>
|
|
49
|
-
<li>Ultimate Power</li>
|
|
50
|
-
</ol>
|
|
51
|
-
<link rel="stylesheet" href="style.css">
|
|
52
|
-
<style>
|
|
53
|
-
body {
|
|
54
|
-
background-color: #222;
|
|
55
|
-
color: white;
|
|
56
|
-
font-family: sans-serif;
|
|
57
|
-
}
|
|
58
|
-
.btn {
|
|
59
|
-
background: gold;
|
|
60
|
-
color: black;
|
|
61
|
-
padding: 10px 20px;
|
|
62
|
-
}
|
|
63
|
-
</style>
|
|
64
|
-
<div class="container">
|
|
65
|
-
<h1>THOTH is Unstoppable!</h1>
|
|
66
|
-
<p>Now with full CSS and JavaScript support.</p>
|
|
67
|
-
<button id="myBtn" class="btn">Click For Magic</button>
|
|
68
|
-
</div>
|
|
69
|
-
<script>
|
|
70
|
-
document.getElementById('myBtn').addEventListener('click', function() {
|
|
71
|
-
alert('THOTH understands JavaScript perfectly!');
|
|
72
|
-
});
|
|
73
|
-
</script>
|
|
74
|
-
<script src="app.js"></script>
|
|
75
|
-
</body>
|
|
76
|
-
</html>
|
package/test.thoth
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
Title style="color: #d4af37; text-align: center;": Welcome to THOTH V2
|
|
2
|
-
Text: Now supporting EVERY HTML element with attributes!
|
|
3
|
-
|
|
4
|
-
Box style="border: 2px dashed #d4af37; padding: 20px; border-radius: 8px;":
|
|
5
|
-
Sub: 1. Full Form Support
|
|
6
|
-
Form:
|
|
7
|
-
Label: Enter your Name:
|
|
8
|
-
Input type="text" placeholder="John Doe":
|
|
9
|
-
Break:
|
|
10
|
-
Label: Choose an option:
|
|
11
|
-
Select:
|
|
12
|
-
Option value="1": Option A
|
|
13
|
-
Option value="2": Option B
|
|
14
|
-
Break:
|
|
15
|
-
Button type="button": Submit Data
|
|
16
|
-
|
|
17
|
-
Line:
|
|
18
|
-
|
|
19
|
-
Sub: 2. Tables and Data
|
|
20
|
-
Table:
|
|
21
|
-
Row:
|
|
22
|
-
Head: ID
|
|
23
|
-
Head: Name
|
|
24
|
-
Head: Role
|
|
25
|
-
Row:
|
|
26
|
-
Data: 1
|
|
27
|
-
Data: Thoth
|
|
28
|
-
Data: Scribe
|
|
29
|
-
Row:
|
|
30
|
-
Data: 2
|
|
31
|
-
Data: Horus
|
|
32
|
-
Data: Guardian
|
|
33
|
-
|
|
34
|
-
Line:
|
|
35
|
-
|
|
36
|
-
Sub: 3. Lists
|
|
37
|
-
OrderedList:
|
|
38
|
-
Item: Clean Syntax
|
|
39
|
-
Item: Python-like Indentation
|
|
40
|
-
Item: Ultimate Power
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
IncludeCss: style.css
|
|
44
|
-
|
|
45
|
-
Style:
|
|
46
|
-
body {
|
|
47
|
-
background-color: #222;
|
|
48
|
-
color: white;
|
|
49
|
-
font-family: sans-serif;
|
|
50
|
-
}
|
|
51
|
-
.btn {
|
|
52
|
-
background: gold;
|
|
53
|
-
color: black;
|
|
54
|
-
padding: 10px 20px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
Box class="container":
|
|
58
|
-
Title: THOTH is Unstoppable!
|
|
59
|
-
Text: Now with full CSS and JavaScript support.
|
|
60
|
-
Button id="myBtn" class="btn": Click For Magic
|
|
61
|
-
|
|
62
|
-
Script:
|
|
63
|
-
document.getElementById('myBtn').addEventListener('click', function() {
|
|
64
|
-
alert('THOTH understands JavaScript perfectly!');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
IncludeJs: app.js
|