thoth-markup-lang 1.0.0 → 3.0.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 +3 -0
- package/README.md +42 -0
- package/package.json +4 -4
- package/thoth-server.php +8 -0
- package/thoth.js +62 -74
- package/test.html +0 -52
- package/test.thoth +0 -41
package/.htaccess
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# <p align="center">𓅓 THOTH: The Pure Dynasty Edition</p>
|
|
2
|
+
|
|
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>
|
|
9
|
+
|
|
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>
|
|
15
|
+
|
|
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
|
|
27
|
+
|
|
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.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 Installation
|
|
38
|
+
|
|
39
|
+
Install the THOTH CLI globally via NPM:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g thoth-markup-lang
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thoth-markup-lang",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Pure Indentation-Based Markup Language by Abdelfatah Abdelhamed",
|
|
5
5
|
"main": "thoth.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"thoth": "./thoth.js"
|
|
8
8
|
},
|
|
9
|
-
"keywords": ["
|
|
10
|
-
"author": "Abdelfatah Abdelhamed",
|
|
9
|
+
"keywords": ["thoth", "no-html", "markup", "egyptian", "clean-code"],
|
|
10
|
+
"author": "Abdelfatah Abdelhamed (Egypt)",
|
|
11
11
|
"license": "MIT"
|
|
12
12
|
}
|
package/thoth-server.php
ADDED
package/thoth.js
CHANGED
|
@@ -1,87 +1,75 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* THOTH Engine v3.0.0 - "Pure Dynasty Edition"
|
|
4
|
+
* Lead Developer: Abdelfatah Abdelhamed 🇪🇬
|
|
5
|
+
*/
|
|
2
6
|
|
|
3
7
|
const fs = require('fs');
|
|
4
8
|
const path = require('path');
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
const
|
|
10
|
+
const command = process.argv[2];
|
|
11
|
+
const file = process.argv[3];
|
|
8
12
|
|
|
9
|
-
if (!
|
|
10
|
-
console.
|
|
11
|
-
console.log('💡 Usage: thoth filename.thoth');
|
|
13
|
+
if (!command || (command !== 'build' && !command.endsWith('.thoth'))) {
|
|
14
|
+
console.log('\x1b[33m%s\x1b[0m', 'Usage: \n thoth build file.thoth (To create HTML)\n thoth file.thoth (Quick Compile)');
|
|
12
15
|
process.exit(1);
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
'
|
|
20
|
-
'
|
|
18
|
+
const targetFile = command === 'build' ? file : command;
|
|
19
|
+
|
|
20
|
+
// القاموس الشامل للمحرك
|
|
21
|
+
const MAP = {
|
|
22
|
+
'Title': 'h1', 'Sub': 'h2', 'Text': 'p', 'Box': 'div', 'Section': 'section',
|
|
23
|
+
'Nav': 'nav', 'Header': 'header', 'Footer': 'footer', 'Bold': 'strong',
|
|
24
|
+
'Link': 'a', 'Image': 'img', 'Button': 'button', 'List': 'ul', 'Item': 'li',
|
|
25
|
+
'Input': 'input', 'Form': 'form', 'Label': 'label', 'Break': 'br'
|
|
21
26
|
};
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// 4. عملية التحليل (الـ Parsing)
|
|
43
|
-
lines.forEach(line => {
|
|
44
|
-
if (line.trim() === '') return;
|
|
45
|
-
|
|
46
|
-
const indent = line.search(/\S/);
|
|
47
|
-
const contentRaw = line.trim();
|
|
48
|
-
|
|
49
|
-
// فصل الأمر، الخصائص، والمحتوى
|
|
50
|
-
const match = contentRaw.match(/^([A-Za-z0-9]+)([^:]*):?(.*)$/);
|
|
51
|
-
if (!match) return;
|
|
52
|
-
|
|
53
|
-
let command = match[1].trim();
|
|
54
|
-
let attributes = match[2].trim();
|
|
55
|
-
let content = match[3].trim();
|
|
56
|
-
|
|
57
|
-
let htmlTag = tagAliases[command] || command.toLowerCase();
|
|
58
|
-
|
|
59
|
-
// إغلاق التاجات المفتوحة إذا قلت المسافات
|
|
60
|
-
while (stack.length > 0 && stack[stack.length - 1].indent >= indent) {
|
|
61
|
-
html += ' '.repeat(stack[stack.length - 1].indent) + `</${stack.pop().name}>\n`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let openTag = `<${htmlTag}${attributes ? ' ' + attributes : ''}>`;
|
|
65
|
-
|
|
66
|
-
if (voidTags.includes(htmlTag)) {
|
|
67
|
-
html += ' '.repeat(indent) + openTag + '\n';
|
|
68
|
-
} else if (content) {
|
|
69
|
-
html += ' '.repeat(indent) + openTag + content + `</${htmlTag}>\n`;
|
|
70
|
-
} else {
|
|
71
|
-
html += ' '.repeat(indent) + openTag + '\n';
|
|
72
|
-
stack.push({ name: htmlTag, indent: indent });
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// إغلاق أي تاجات متبقية
|
|
77
|
-
while (stack.length > 0) {
|
|
78
|
-
html += ' '.repeat(stack[stack.length - 1].indent) + `</${stack.pop().name}>\n`;
|
|
79
|
-
}
|
|
28
|
+
const VOID = ['img', 'br', 'hr', 'input', 'meta', 'link'];
|
|
29
|
+
|
|
30
|
+
function compile(filePath) {
|
|
31
|
+
const code = fs.readFileSync(filePath, 'utf8');
|
|
32
|
+
const lines = code.split(/\r?\n/);
|
|
33
|
+
let htmlBody = "";
|
|
34
|
+
let stack = [];
|
|
35
|
+
let inRaw = false, rawType = '', rawIndent = 0;
|
|
36
|
+
|
|
37
|
+
lines.forEach(line => {
|
|
38
|
+
if (!line.trim() || line.trim().startsWith('#')) return;
|
|
39
|
+
const indent = line.search(/\S/);
|
|
40
|
+
const clean = line.trim();
|
|
41
|
+
|
|
42
|
+
if (inRaw) {
|
|
43
|
+
if (indent <= rawIndent && clean !== "") { inRaw = false; htmlBody += `</${rawType}>\n`; }
|
|
44
|
+
else { htmlBody += line + '\n'; return; }
|
|
45
|
+
}
|
|
80
46
|
|
|
81
|
-
|
|
47
|
+
const match = clean.match(/^([A-Za-z0-9]+)([^:]*):?(.*)$/);
|
|
48
|
+
if (!match) return;
|
|
49
|
+
let [_, cmd, attrs, val] = match;
|
|
82
50
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
51
|
+
if (cmd === "StyleSheet" || cmd === "Scripting") {
|
|
52
|
+
inRaw = true; rawType = (cmd === "StyleSheet") ? "style" : "script";
|
|
53
|
+
rawIndent = indent; htmlBody += `<${rawType}>\n`; return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
while (stack.length > 0 && stack[stack.length - 1].indent >= indent) {
|
|
57
|
+
htmlBody += `</${stack.pop().name}>\n`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let tag = MAP[cmd] || cmd.toLowerCase();
|
|
61
|
+
let open = `<${tag}${attrs.trim() ? ' ' + attrs.trim() : ''}>`;
|
|
62
|
+
|
|
63
|
+
if (VOID.includes(tag)) htmlBody += open + '\n';
|
|
64
|
+
else if (val.trim()) htmlBody += `${open}${val.trim()}</${tag}>\n`;
|
|
65
|
+
else { htmlBody += open + '\n'; stack.push({ name: tag, indent: indent }); }
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
while (stack.length > 0) htmlBody += `</${stack.pop().name}>\n`;
|
|
69
|
+
return `<!DOCTYPE html><html><head><meta charset="UTF-8"><title>THOTH Pure Web</title></head><body>${htmlBody}</body></html>`;
|
|
70
|
+
}
|
|
86
71
|
|
|
87
|
-
|
|
72
|
+
const result = compile(targetFile);
|
|
73
|
+
const output = targetFile.replace('.thoth', '.html');
|
|
74
|
+
fs.writeFileSync(output, result);
|
|
75
|
+
console.log('\x1b[32m%s\x1b[0m', `✔ THOTH v3.0: Generated Successfully [By Abdelfatah Abdelhamed]`);
|
package/test.html
DELETED
|
@@ -1,52 +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 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
|
-
</body>
|
|
52
|
-
</html>
|
package/test.thoth
DELETED
|
@@ -1,41 +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
|
-
|