thoth-markup-lang 1.0.0 → 1.0.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ # 𓅓 THOTH Markup Language
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!
4
+
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)
7
+
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**.
10
+
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.
13
+
14
+ ---
15
+
16
+ ## 🚀 Installation
17
+
18
+ Install THOTH globally on your machine using NPM:
19
+
20
+ ```bash
21
+ npm install -g thoth-markup-lang
package/index.html ADDED
@@ -0,0 +1,22 @@
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 ADDED
@@ -0,0 +1,13 @@
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thoth-markup-lang",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "The Pythonic Architect of the Web - HTML alternative",
5
5
  "main": "thoth.js",
6
6
  "bin": {
package/test.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>THOTH Output</title>
6
+ <title>THOTH Web App</title>
7
7
  </head>
8
8
  <body>
9
9
  <h1 style="color>#d4af37; text-align: center;": Welcome to THOTH V2</h1>
@@ -48,5 +48,29 @@
48
48
  <li>Python-like Indentation</li>
49
49
  <li>Ultimate Power</li>
50
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>
51
75
  </body>
52
76
  </html>
package/test.thoth CHANGED
@@ -38,4 +38,30 @@ Box style="border: 2px dashed #d4af37; padding: 20px; border-radius: 8px;":
38
38
  Item: Clean Syntax
39
39
  Item: Python-like Indentation
40
40
  Item: Ultimate Power
41
-
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
package/thoth.js CHANGED
@@ -1,9 +1,8 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
 
6
- // 1. استقبال اسم الملف من سطر الأوامر
7
6
  const inputFile = process.argv[2];
8
7
 
9
8
  if (!inputFile || path.extname(inputFile) !== '.thoth') {
@@ -12,41 +11,46 @@ if (!inputFile || path.extname(inputFile) !== '.thoth') {
12
11
  process.exit(1);
13
12
  }
14
13
 
15
- // 2. القواميس (دعم الكلمات المختصرة وكل تاجات HTML)
16
14
  const tagAliases = {
17
15
  'Title': 'h1', 'Sub': 'h2', 'Text': 'p', 'Bold': 'strong', 'Italic': 'em',
18
16
  'Box': 'div', 'Link': 'a', 'Image': 'img', 'List': 'ul', 'OrderedList': 'ol',
19
- 'Item': 'li', 'Row': 'tr', 'Head': 'th', 'Data': 'td', 'Quote': 'blockquote',
20
- 'Line': 'hr', 'Break': 'br'
17
+ 'Item': 'li', 'Row': 'tr', 'Head': 'th', 'Data': 'td', 'Line': 'hr', 'Break': 'br',
18
+ // الأوامر الجديدة لربط الملفات الخارجية بسرعة
19
+ 'IncludeCss': 'link',
20
+ 'IncludeJs': 'script'
21
21
  };
22
22
 
23
- // التاجات التي لا تحتاج إغلاق
24
23
  const voidTags = ['img', 'br', 'hr', 'input', 'meta', 'link', 'source'];
25
24
 
26
- // 3. قراءة ملف الـ THOTH
27
25
  const code = fs.readFileSync(inputFile, 'utf8');
28
26
  const lines = code.split('\n');
29
27
 
30
- // تجهيز هيكل ملف الـ HTML الأساسي
31
- let html = `<!DOCTYPE html>
32
- <html lang="en">
33
- <head>
34
- <meta charset="UTF-8">
35
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
36
- <title>THOTH Output</title>
37
- </head>
38
- <body>
39
- `;
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`;
40
29
  let stack = [];
41
30
 
42
- // 4. عملية التحليل (الـ Parsing)
31
+ // متغيرات نظام (Raw Mode) للأكواد الداخلية
32
+ let inRawMode = false;
33
+ let rawIndentLevel = 0;
34
+ let rawTagName = '';
35
+
43
36
  lines.forEach(line => {
44
37
  if (line.trim() === '') return;
45
38
 
46
39
  const indent = line.search(/\S/);
47
40
  const contentRaw = line.trim();
48
-
49
- // فصل الأمر، الخصائص، والمحتوى
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
+
50
54
  const match = contentRaw.match(/^([A-Za-z0-9]+)([^:]*):?(.*)$/);
51
55
  if (!match) return;
52
56
 
@@ -56,12 +60,30 @@ lines.forEach(line => {
56
60
 
57
61
  let htmlTag = tagAliases[command] || command.toLowerCase();
58
62
 
59
- // إغلاق التاجات المفتوحة إذا قلت المسافات
60
63
  while (stack.length > 0 && stack[stack.length - 1].indent >= indent) {
61
64
  html += ' '.repeat(stack[stack.length - 1].indent) + `</${stack.pop().name}>\n`;
62
65
  }
63
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
+
64
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
+ }
65
87
 
66
88
  if (voidTags.includes(htmlTag)) {
67
89
  html += ' '.repeat(indent) + openTag + '\n';
@@ -73,15 +95,17 @@ lines.forEach(line => {
73
95
  }
74
96
  });
75
97
 
76
- // إغلاق أي تاجات متبقية
98
+ // إغلاق أي أكواد مفتوحة في نهاية الملف
99
+ if (inRawMode) {
100
+ html += ' '.repeat(rawIndentLevel) + `</${rawTagName}>\n`;
101
+ }
77
102
  while (stack.length > 0) {
78
103
  html += ' '.repeat(stack[stack.length - 1].indent) + `</${stack.pop().name}>\n`;
79
104
  }
80
105
 
81
106
  html += '</body>\n</html>';
82
107
 
83
- // 5. كتابة ملف الـ HTML الجديد
84
108
  const outputFile = inputFile.replace('.thoth', '.html');
85
109
  fs.writeFileSync(outputFile, html);
86
110
 
87
- console.log(`✅ Success! Compiled ${inputFile} -> ${outputFile}`);
111
+ console.log(`✅ Success! Compiled with CSS/JS Support -> ${outputFile}`);