thoth-markup-lang 1.0.2 → 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 ADDED
@@ -0,0 +1,3 @@
1
+ RewriteEngine On
2
+ RewriteCond %{REQUEST_FILENAME} !-f
3
+ RewriteRule ^(.*)$ engine.php?file=$1.thoth [L,QSA]
package/README.md CHANGED
@@ -1,21 +1,42 @@
1
- # 𓅓 THOTH Markup Language
1
+ # <p align="center">𓅓 THOTH: The Pure Dynasty Edition</p>
2
2
 
3
- > **The Pythonic Architect of the Web.** > Write clean, indentation-based markup that compiles instantly into standard HTML. No more messy brackets or endless closing tags!
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
- ![NPM Version](https://img.shields.io/npm/v/thoth-markup-lang?color=gold&style=for-the-badge)
6
- ![License](https://img.shields.io/npm/l/thoth-markup-lang?style=for-the-badge)
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
- ## 🌟 Why THOTH?
9
- Writing HTML can sometimes feel repetitive and cluttered with angle brackets (`< >`) and closing tags (`</ >`). **THOTH** solves this by adopting a **Python-like indentation system**.
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
- If a line is indented under another, it becomes its child. It's that simple.
12
- THOTH supports **100% of all HTML elements and attributes** out of the box, combining the raw power of HTML with the aesthetic cleanliness of Python.
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 on your machine using NPM:
39
+ Install the THOTH CLI globally via NPM:
19
40
 
20
41
  ```bash
21
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": "1.0.2",
4
- "description": "The Pythonic Architect of the Web - HTML alternative",
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": ["html", "markup", "pythonic", "thoth", "parser"],
10
- "author": "Abdelfatah Abdelhamed",
9
+ "keywords": ["thoth", "no-html", "markup", "egyptian", "clean-code"],
10
+ "author": "Abdelfatah Abdelhamed (Egypt)",
11
11
  "license": "MIT"
12
12
  }
@@ -0,0 +1,8 @@
1
+ <?php
2
+ // THOTH Server Runtime v3.0
3
+ function renderThoth($file) {
4
+ $content = file_get_contents($file);
5
+ // (هنا نضع نفس منطق التحويل الموجود في JS ولكن بلغة PHP)
6
+ echo "";
7
+ // ... منطق التحويل ...
8
+ }
package/thoth.js CHANGED
@@ -1,111 +1,75 @@
1
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
- const inputFile = process.argv[2];
10
+ const command = process.argv[2];
11
+ const file = process.argv[3];
7
12
 
8
- if (!inputFile || path.extname(inputFile) !== '.thoth') {
9
- console.error(' Error: Please provide a valid .thoth file.');
10
- 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)');
11
15
  process.exit(1);
12
16
  }
13
17
 
14
- const tagAliases = {
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'
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
- 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();
60
-
61
- let htmlTag = tagAliases[command] || command.toLowerCase();
62
-
63
- while (stack.length > 0 && stack[stack.length - 1].indent >= indent) {
64
- html += ' '.repeat(stack[stack.length - 1].indent) + `</${stack.pop().name}>\n`;
65
- }
66
-
67
- // أوامر الربط السريع للملفات الخارجية
68
- if (command === 'IncludeCss') {
69
- html += ' '.repeat(indent) + `<link rel="stylesheet" href="${content}">\n`;
70
- return;
71
- }
72
- if (command === 'IncludeJs') {
73
- html += ' '.repeat(indent) + `<script src="${content}"></script>\n`;
74
- return;
75
- }
76
-
77
- let openTag = `<${htmlTag}${attributes ? ' ' + attributes : ''}>`;
78
-
79
- // الدخول في وضع الـ Raw Mode لو الأمر Style أو Script
80
- if ((htmlTag === 'style' || htmlTag === 'script') && !content) {
81
- inRawMode = true;
82
- rawIndentLevel = indent;
83
- rawTagName = htmlTag;
84
- html += ' '.repeat(indent) + openTag + '\n';
85
- return;
86
- }
87
-
88
- if (voidTags.includes(htmlTag)) {
89
- html += ' '.repeat(indent) + openTag + '\n';
90
- } else if (content) {
91
- html += ' '.repeat(indent) + openTag + content + `</${htmlTag}>\n`;
92
- } else {
93
- html += ' '.repeat(indent) + openTag + '\n';
94
- stack.push({ name: htmlTag, indent: indent });
95
- }
96
- });
97
-
98
- // إغلاق أي أكواد مفتوحة في نهاية الملف
99
- if (inRawMode) {
100
- html += ' '.repeat(rawIndentLevel) + `</${rawTagName}>\n`;
101
- }
102
- while (stack.length > 0) {
103
- html += ' '.repeat(stack[stack.length - 1].indent) + `</${stack.pop().name}>\n`;
104
- }
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
+ }
105
46
 
106
- html += '</body>\n</html>';
47
+ const match = clean.match(/^([A-Za-z0-9]+)([^:]*):?(.*)$/);
48
+ if (!match) return;
49
+ let [_, cmd, attrs, val] = match;
107
50
 
108
- const outputFile = inputFile.replace('.thoth', '.html');
109
- fs.writeFileSync(outputFile, html);
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
+ }
110
71
 
111
- console.log(`✅ Success! Compiled with CSS/JS Support -> ${outputFile}`);
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/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