htmlxify 1.0.0__tar.gz → 1.0.1__tar.gz

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.
Files changed (24) hide show
  1. {htmlxify-1.0.0 → htmlxify-1.0.1}/PKG-INFO +34 -7
  2. {htmlxify-1.0.0 → htmlxify-1.0.1}/README.md +33 -6
  3. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/cli.py +29 -9
  4. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/generators/html_gen.py +32 -2
  5. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/parser/ast_builder.py +34 -4
  6. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/parser/grammar.lark +23 -8
  7. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/validator/semantic.py +55 -7
  8. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify.egg-info/PKG-INFO +34 -7
  9. {htmlxify-1.0.0 → htmlxify-1.0.1}/setup.py +1 -1
  10. {htmlxify-1.0.0 → htmlxify-1.0.1}/LICENSE +0 -0
  11. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/__init__.py +0 -0
  12. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/generators/__init__.py +0 -0
  13. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/generators/css_gen.py +0 -0
  14. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/generators/js_gen.py +0 -0
  15. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/parser/__init__.py +0 -0
  16. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/parser/indent_processor.py +0 -0
  17. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/utils/__init__.py +0 -0
  18. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify/validator/__init__.py +0 -0
  19. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify.egg-info/SOURCES.txt +0 -0
  20. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify.egg-info/dependency_links.txt +0 -0
  21. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify.egg-info/entry_points.txt +0 -0
  22. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify.egg-info/requires.txt +0 -0
  23. {htmlxify-1.0.0 → htmlxify-1.0.1}/htmlxify.egg-info/top_level.txt +0 -0
  24. {htmlxify-1.0.0 → htmlxify-1.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: htmlxify
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: htmlxify - A simplified web markup language compiler that transpiles to HTML, CSS, and JavaScript
5
5
  Home-page: https://github.com/Aquib489/htmlxify
6
6
  Author: Aquib489
@@ -134,6 +134,9 @@ HTMLXIFY page.HTMLXIFY output/
134
134
  - ✅ **XSS Protection** - Automatic HTML escaping for security
135
135
  - ✅ **Fast Compilation** - Single-pass compiler, instant results
136
136
  - ✅ **Production Ready** - Generates clean, optimized code
137
+ - ✅ **Void Elements** - Proper `<br>`, `<img>`, `<input>`, `<meta>`, etc. handling
138
+ - ✅ **Escape Sequences** - Support for `/{`, `/}`, `/(`, `/)`
139
+ - ✅ **Boolean Attributes** - HTML5 booleans like `disabled`, `checked`, `required`
137
140
 
138
141
  ## 📋 Implementation Status
139
142
 
@@ -221,7 +224,9 @@ This generates:
221
224
 
222
225
  Open `output/hello.html` in your browser and you're done! 🎉
223
226
 
224
- **That's it!** No configuration, no build tools. Just HTML, CSS, and JS.## 📖 Language Syntax Guide
227
+ **That's it!** No configuration, no build tools. Just HTML, CSS, and JS.
228
+
229
+ ## 📖 Language Syntax Guide
225
230
 
226
231
  ### Basic Elements
227
232
 
@@ -231,6 +236,12 @@ div { Content }
231
236
  p { Paragraph }
232
237
  h1 { Heading }
233
238
  button { Click Me }
239
+
240
+ // Void elements (no closing tag)
241
+ br
242
+ img(src: "photo.jpg", alt: "Photo")
243
+ input(type: "text")
244
+ meta(charset: "UTF-8")
234
245
  ```
235
246
 
236
247
  ### Classes & IDs
@@ -252,14 +263,30 @@ div.card#featured { ... }
252
263
  ### Attributes
253
264
 
254
265
  ```markup
255
- // Simple attributes
266
+ // String attributes
256
267
  button(onclick: "handleClick") { Click }
268
+ a(href: "https://example.com", target: "_blank") { Link }
257
269
 
258
- // Multiple attributes
259
- input(type: "email", placeholder: "Enter email", required: true)
270
+ // Boolean attributes (no value)
271
+ input(type: "checkbox", checked)
272
+ input(type: "text", disabled)
273
+ button(disabled) { Can't Click }
274
+ form(novalidate) { ... }
275
+ ```
260
276
 
261
- // String values
262
- a(href: "https://example.com", target: "_blank") { Link }
277
+ ### Escape Sequences
278
+
279
+ When you need characters that conflict with syntax, use escape sequences:
280
+
281
+ ```markup
282
+ // Escaped curly braces
283
+ p { JSON: /{ "key": "value" /} }
284
+
285
+ // Escaped parentheses
286
+ code { function/(/)/() /{ return true; /} }
287
+
288
+ // Real-world example
289
+ p { Price: $99.99 (50% off) and formula: x^2 }
263
290
  ```
264
291
 
265
292
  ### Nesting
@@ -73,6 +73,9 @@ HTMLXIFY page.HTMLXIFY output/
73
73
  - ✅ **XSS Protection** - Automatic HTML escaping for security
74
74
  - ✅ **Fast Compilation** - Single-pass compiler, instant results
75
75
  - ✅ **Production Ready** - Generates clean, optimized code
76
+ - ✅ **Void Elements** - Proper `<br>`, `<img>`, `<input>`, `<meta>`, etc. handling
77
+ - ✅ **Escape Sequences** - Support for `/{`, `/}`, `/(`, `/)`
78
+ - ✅ **Boolean Attributes** - HTML5 booleans like `disabled`, `checked`, `required`
76
79
 
77
80
  ## 📋 Implementation Status
78
81
 
@@ -160,7 +163,9 @@ This generates:
160
163
 
161
164
  Open `output/hello.html` in your browser and you're done! 🎉
162
165
 
163
- **That's it!** No configuration, no build tools. Just HTML, CSS, and JS.## 📖 Language Syntax Guide
166
+ **That's it!** No configuration, no build tools. Just HTML, CSS, and JS.
167
+
168
+ ## 📖 Language Syntax Guide
164
169
 
165
170
  ### Basic Elements
166
171
 
@@ -170,6 +175,12 @@ div { Content }
170
175
  p { Paragraph }
171
176
  h1 { Heading }
172
177
  button { Click Me }
178
+
179
+ // Void elements (no closing tag)
180
+ br
181
+ img(src: "photo.jpg", alt: "Photo")
182
+ input(type: "text")
183
+ meta(charset: "UTF-8")
173
184
  ```
174
185
 
175
186
  ### Classes & IDs
@@ -191,14 +202,30 @@ div.card#featured { ... }
191
202
  ### Attributes
192
203
 
193
204
  ```markup
194
- // Simple attributes
205
+ // String attributes
195
206
  button(onclick: "handleClick") { Click }
207
+ a(href: "https://example.com", target: "_blank") { Link }
196
208
 
197
- // Multiple attributes
198
- input(type: "email", placeholder: "Enter email", required: true)
209
+ // Boolean attributes (no value)
210
+ input(type: "checkbox", checked)
211
+ input(type: "text", disabled)
212
+ button(disabled) { Can't Click }
213
+ form(novalidate) { ... }
214
+ ```
199
215
 
200
- // String values
201
- a(href: "https://example.com", target: "_blank") { Link }
216
+ ### Escape Sequences
217
+
218
+ When you need characters that conflict with syntax, use escape sequences:
219
+
220
+ ```markup
221
+ // Escaped curly braces
222
+ p { JSON: /{ "key": "value" /} }
223
+
224
+ // Escaped parentheses
225
+ code { function/(/)/() /{ return true; /} }
226
+
227
+ // Real-world example
228
+ p { Price: $99.99 (50% off) and formula: x^2 }
202
229
  ```
203
230
 
204
231
  ### Nesting
@@ -86,53 +86,73 @@ def main():
86
86
 
87
87
  # Step 3: Validate
88
88
  if args.verbose:
89
- print("Step 3/6: Validating...")
89
+ print("Step 3/7: Validating...")
90
90
 
91
91
  validator = SemanticValidator(ast, input_path.name)
92
92
  if not validator.validate():
93
93
  sys.exit(1)
94
94
  print("OK - Validation complete")
95
95
 
96
- # Step 4: Create output directory
96
+ # Step 4: Create output directory (after validation passes)
97
+ if args.verbose:
98
+ print("Step 4/7: Creating output directory...")
99
+
97
100
  output_dir = Path(args.output)
98
101
  output_dir.mkdir(exist_ok=True, parents=True)
102
+ print("OK - Output directory ready")
99
103
 
100
104
  # Step 5: Generate HTML
101
105
  if args.verbose:
102
- print("Step 4/6: Generating HTML...")
106
+ print("Step 5/7: Generating HTML...")
103
107
 
104
108
  html_gen = HTMLGenerator(ast, input_path.name)
105
109
  html, source_map = html_gen.generate()
106
110
 
107
111
  html_path = output_dir / input_path.name.replace('.htmlxify', '.html')
108
- html_path.write_text(html, encoding='utf-8')
112
+ try:
113
+ html_path.write_text(html, encoding='utf-8')
114
+ except IOError as e:
115
+ print(f"ERROR: Failed to write HTML file: {e}")
116
+ sys.exit(1)
109
117
 
110
118
  # Write source map
111
119
  source_map_path = output_dir / (input_path.name.replace('.htmlxify', '.html') + '.map')
112
- source_map_path.write_text(source_map, encoding='utf-8')
120
+ try:
121
+ source_map_path.write_text(source_map, encoding='utf-8')
122
+ except IOError as e:
123
+ print(f"ERROR: Failed to write source map: {e}")
124
+ sys.exit(1)
113
125
 
114
126
  print(f"OK - Generated {html_path}")
115
127
 
116
128
  # Step 6: Generate CSS
117
129
  if args.verbose:
118
- print("Step 5/6: Generating CSS...")
130
+ print("Step 6/7: Generating CSS...")
119
131
 
120
132
  css_gen = CSSGenerator(ast)
121
133
  css = css_gen.generate()
122
134
 
123
135
  css_path = output_dir / input_path.name.replace('.htmlxify', '.css')
124
- css_path.write_text(css, encoding='utf-8')
136
+ try:
137
+ css_path.write_text(css, encoding='utf-8')
138
+ except IOError as e:
139
+ print(f"ERROR: Failed to write CSS file: {e}")
140
+ sys.exit(1)
125
141
  print(f"OK - Generated {css_path}")
126
142
 
127
143
  # Step 7: Generate JavaScript
128
144
  if args.verbose:
129
- print("Step 6/6: Generating JavaScript...")
145
+ print("Step 7/7: Generating JavaScript...")
130
146
 
131
147
  js_gen = JSGenerator(ast)
132
148
  js = js_gen.generate()
133
149
 
134
150
  js_path = output_dir / input_path.name.replace('.htmlxify', '.js')
135
- js_path.write_text(js, encoding='utf-8')
151
+ try:
152
+ js_path.write_text(js, encoding='utf-8')
153
+ except IOError as e:
154
+ print(f"ERROR: Failed to write JavaScript file: {e}")
155
+ sys.exit(1)
136
156
  print(f"OK - Generated {js_path}")
137
157
 
138
158
  print("\nCompilation successful!\n")
@@ -14,8 +14,17 @@ class HTMLGenerator:
14
14
  - Automatic HTML escaping
15
15
  - XSS prevention
16
16
  - Source map generation for debugging
17
+ - Proper handling of void (self-closing) elements
17
18
  """
18
19
 
20
+ # HTML5 void elements - these cannot have closing tags
21
+ VOID_ELEMENTS = frozenset({
22
+ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
23
+ 'link', 'meta', 'param', 'source', 'track', 'wbr',
24
+ # Deprecated but still valid
25
+ 'command', 'keygen', 'menuitem'
26
+ })
27
+
19
28
  def __init__(self, ast: Dict[str, Any], filename: str):
20
29
  self.ast = ast
21
30
  self.filename = filename
@@ -69,7 +78,8 @@ class HTMLGenerator:
69
78
  def _generate_element(self, node: Dict[str, Any], depth: int):
70
79
  """Generate HTML element"""
71
80
  indent = ' ' * depth
72
- tag = node.get('tag', 'div')
81
+ tag = node.get('tag', 'div').lower()
82
+ is_void = tag in self.VOID_ELEMENTS
73
83
 
74
84
  # Opening tag
75
85
  self.output.append(f'{indent}<{tag}')
@@ -88,6 +98,12 @@ class HTMLGenerator:
88
98
  # Other attributes
89
99
  self._generate_attributes(node.get('attributes', {}))
90
100
 
101
+ # For void elements, close with > and no closing tag
102
+ if is_void:
103
+ self.output.append('>\n')
104
+ self.current_line += 1
105
+ return
106
+
91
107
  self.output.append('>')
92
108
 
93
109
  # Children
@@ -107,6 +123,15 @@ class HTMLGenerator:
107
123
 
108
124
  def _generate_attributes(self, attrs: Dict[str, Any]):
109
125
  """Generate HTML attributes"""
126
+ # HTML5 boolean attributes - rendered without value
127
+ BOOLEAN_ATTRS = {
128
+ 'disabled', 'checked', 'readonly', 'required', 'autofocus',
129
+ 'autoplay', 'controls', 'loop', 'muted', 'default', 'defer',
130
+ 'async', 'hidden', 'ismap', 'multiple', 'novalidate', 'open',
131
+ 'reversed', 'selected', 'allowfullscreen', 'formnovalidate',
132
+ 'itemscope', 'nomodule', 'playsinline'
133
+ }
134
+
110
135
  for key, value in attrs.items():
111
136
  if key == '⚡-call':
112
137
  # Backend API call - convert to data attribute
@@ -128,8 +153,13 @@ class HTMLGenerator:
128
153
  safe_key = html_escape_module.escape(data_key, quote=True)
129
154
  self.output.append(f' data-dynamic="{safe_key}"')
130
155
 
156
+ elif value is True or (key.lower() in BOOLEAN_ATTRS and value is True):
157
+ # Boolean attribute - render without value
158
+ safe_key = html_escape_module.escape(str(key), quote=True)
159
+ self.output.append(f' {safe_key}')
160
+
131
161
  else:
132
- # Regular attribute
162
+ # Regular attribute with value
133
163
  safe_key = html_escape_module.escape(str(key), quote=True)
134
164
  safe_value = html_escape_module.escape(str(value), quote=True)
135
165
  self.output.append(f' {safe_key}="{safe_value}"')
@@ -116,17 +116,27 @@ class ASTTransformer(Transformer):
116
116
  result.update(attr)
117
117
  return result
118
118
 
119
- def attribute(self, children: list) -> Dict[str, Any]:
119
+ def key_value_attr(self, children: list) -> Dict[str, Any]:
120
120
  """
121
- attribute: attr_key ":" attr_value
121
+ key_value_attr: attr_key ":" attr_value
122
122
  Lark filters out ":", so children = [key, value]
123
123
  """
124
124
  if len(children) >= 2:
125
125
  key = str(children[0])
126
- value = children[1]
126
+ value = str(children[1]) if children[1] is not None else ""
127
127
  return {key: value}
128
128
  return {}
129
129
 
130
+ def boolean_attr(self, children: list) -> Dict[str, Any]:
131
+ """
132
+ boolean_attr: attr_key (no value)
133
+ For HTML boolean attributes like disabled, checked, readonly, required
134
+ """
135
+ if children:
136
+ key = str(children[0])
137
+ return {key: True} # True indicates boolean attribute
138
+ return {}
139
+
130
140
  def attr_key(self, children: list) -> str:
131
141
  """attr_key: SPECIAL_ATTR | WORD"""
132
142
  return str(children[0])
@@ -208,7 +218,7 @@ class ASTTransformer(Transformer):
208
218
  return None
209
219
 
210
220
  def text_token(self, children: list) -> str:
211
- """text_token: TEXT_CHUNK | WORD"""
221
+ """text_token: ESCAPED_* | TEXT_CHUNK | WORD"""
212
222
  return str(children[0]) if children else ''
213
223
 
214
224
  # ============================================================
@@ -221,6 +231,22 @@ class ASTTransformer(Transformer):
221
231
  def TEXT_CHUNK(self, token: Token) -> str:
222
232
  return str(token)
223
233
 
234
+ def ESCAPED_OPEN_BRACE(self, token: Token) -> str:
235
+ """Convert /{ to literal {"""
236
+ return '{'
237
+
238
+ def ESCAPED_CLOSE_BRACE(self, token: Token) -> str:
239
+ """Convert /} to literal }"""
240
+ return '}'
241
+
242
+ def ESCAPED_OPEN_PAREN(self, token: Token) -> str:
243
+ """Convert /( to literal ("""
244
+ return '('
245
+
246
+ def ESCAPED_CLOSE_PAREN(self, token: Token) -> str:
247
+ """Convert /) to literal )"""
248
+ return ')'
249
+
224
250
  def STRING(self, token: Token) -> str:
225
251
  """Remove quotes from strings"""
226
252
  s = str(token)
@@ -240,6 +266,10 @@ class ASTTransformer(Transformer):
240
266
 
241
267
  def SPECIAL_ATTR(self, token: Token) -> str:
242
268
  return str(token)
269
+
270
+ def COMMENT(self, token: Token) -> None:
271
+ """Comments are discarded - return None"""
272
+ return None
243
273
 
244
274
 
245
275
 
@@ -22,7 +22,9 @@ attributes: "(" attr_list ")"
22
22
 
23
23
  attr_list: attribute ("," attribute)*
24
24
 
25
- attribute: attr_key ":" attr_value
25
+ // Support both key:value and boolean attributes (key only)
26
+ attribute: attr_key ":" attr_value -> key_value_attr
27
+ | attr_key -> boolean_attr
26
28
 
27
29
  attr_key: SPECIAL_ATTR | WORD
28
30
 
@@ -42,28 +44,41 @@ body_item: full_element -> body_element
42
44
  | text_content -> body_text
43
45
 
44
46
  // full_element: Has either attributes, body, or both (this disambiguates from plain text)
45
- full_element: WORD class_sel* id_sel? (attributes | body | attributes body)
47
+ full_element: WORD class_sel* id_sel? (attributes body | attributes | body)
46
48
 
47
49
  // text_content: Text chunks or plain words
48
50
  text_content: text_token+
49
51
 
50
- text_token: TEXT_CHUNK | WORD
52
+ text_token: ESCAPED_OPEN_BRACE
53
+ | ESCAPED_CLOSE_BRACE
54
+ | ESCAPED_OPEN_PAREN
55
+ | ESCAPED_CLOSE_PAREN
56
+ | TEXT_CHUNK
57
+ | WORD
51
58
 
52
59
  // ============================================================
53
60
  // TERMINALS
54
61
  // ============================================================
55
62
 
56
- COMMENT: "//" /[^\n]*/
63
+ COMMENT: "/" + "/" /[^\n]*/
57
64
 
58
65
  SPECIAL_ATTR.10: "⚡-call" | "⚡-data"
59
66
 
60
- STRING.9: /"[^"]*"/ | /'[^']*'/
67
+ // Escaped special characters
68
+ ESCAPED_OPEN_BRACE.9: "/{"
69
+ ESCAPED_CLOSE_BRACE.9: "/}"
70
+ ESCAPED_OPEN_PAREN.9: "/("
71
+ ESCAPED_CLOSE_PAREN.9: "/)"
61
72
 
62
- NUMBER.8: /-?\d+\.?\d*/
73
+ STRING.8: /"[^"]*"/ | /'[^']*'/
63
74
 
64
- WORD.7: /[a-zA-Z_][a-zA-Z0-9_-]*/
75
+ NUMBER.7: /-?\d+\.?\d*/
65
76
 
66
- TEXT_CHUNK.1: /[a-zA-Z0-9.!?;:'"&%$@*+=<>\/\[\]\\|~`\s\-–—,]+/
77
+ WORD.6: /[a-zA-Z_][a-zA-Z0-9_-]*/
78
+
79
+ // Text content - includes most printable characters except structural ones { } ( )
80
+ // Structural chars need escaping: /{ /} /( /)
81
+ TEXT_CHUNK.1: /[a-zA-Z0-9.!?;:'"&%$@*+=<>\/\[\]\\|~`\s\-–—,#^_]+/
67
82
 
68
83
  %import common.WS
69
84
  %ignore WS
@@ -33,13 +33,30 @@ class SemanticValidator:
33
33
  - Performance anti-patterns
34
34
  - Security issues
35
35
  - Component naming conventions
36
+ - Void element misuse
36
37
  """
37
38
 
38
- # Valid identifier pattern (JavaScript-compatible)
39
- IDENTIFIER_PATTERN = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_-]*$')
39
+ # Valid identifier pattern (JavaScript-compatible - no hyphens in IDs)
40
+ IDENTIFIER_PATTERN = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
40
41
 
41
- # Component name pattern (must have hyphen)
42
- COMPONENT_PATTERN = re.compile(r'^[a-z]+-[a-z-]+$')
42
+ # Component name pattern (must have hyphen, allow digits)
43
+ COMPONENT_PATTERN = re.compile(r'^[a-z][a-z0-9]*-[a-z0-9-]+$')
44
+
45
+ # HTML5 boolean attributes - cannot have children or closing tags
46
+ VOID_ELEMENTS = frozenset({
47
+ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
48
+ 'link', 'meta', 'param', 'source', 'track', 'wbr',
49
+ 'command', 'keygen', 'menuitem'
50
+ })
51
+
52
+ # Valid HTML5 boolean attributes
53
+ VALID_BOOLEAN_ATTRS = frozenset({
54
+ 'disabled', 'checked', 'readonly', 'required', 'selected',
55
+ 'async', 'defer', 'autofocus', 'autoplay', 'loop', 'muted',
56
+ 'default', 'controls', 'open', 'reversed', 'allowfullscreen',
57
+ 'formnovalidate', 'itemscope', 'nomodule', 'playsinline', 'hidden',
58
+ 'multiple', 'novalidate', 'ismap'
59
+ })
43
60
 
44
61
  def __init__(self, ast: Dict[str, Any], filename: str):
45
62
  self.ast = ast
@@ -109,19 +126,50 @@ class SemanticValidator:
109
126
  tag = node.get('tag', '')
110
127
  if 'component' in tag.lower() or '-' in tag:
111
128
  # This is a custom component
112
- if not self.COMPONENT_PATTERN.match(tag):
129
+ if not self.COMPONENT_PATTERN.match(tag.lower()):
113
130
  self.errors.append(ValidationIssue(
114
131
  node,
115
132
  f"Component names must be lowercase with hyphen: '{tag}' → 'my-component'",
116
133
  severity='error'
117
134
  ))
118
135
 
119
- # 4. Performance warnings
136
+ # 4. Check for void elements with children
137
+ self._check_void_element(node)
138
+
139
+ # 5. Validate boolean attributes
140
+ self._validate_boolean_attributes(node)
141
+
142
+ # 6. Performance warnings
120
143
  self._check_performance(node)
121
144
 
122
- # 5. Security checks
145
+ # 7. Security checks
123
146
  self._check_security(node)
124
147
 
148
+ def _validate_boolean_attributes(self, node: Dict[str, Any]):
149
+ """Check if boolean attributes are valid HTML5 attributes"""
150
+ attrs = node.get('attributes', {})
151
+ for key, value in attrs.items():
152
+ if value is True and key not in self.VALID_BOOLEAN_ATTRS:
153
+ self.errors.append(ValidationIssue(
154
+ node,
155
+ f"'{key}' is not a valid HTML5 boolean attribute. "
156
+ f"Use one of: {', '.join(sorted(self.VALID_BOOLEAN_ATTRS))}",
157
+ severity='error'
158
+ ))
159
+
160
+ def _check_void_element(self, node: Dict[str, Any]):
161
+ """Check if void elements are used correctly (no children allowed)"""
162
+ tag = node.get('tag', '').lower()
163
+ children = node.get('children', [])
164
+
165
+ if tag in self.VOID_ELEMENTS and children:
166
+ self.errors.append(ValidationIssue(
167
+ node,
168
+ f"Void element '<{tag}>' cannot have children. "
169
+ f"Elements like <br>, <img>, <input>, <hr>, <meta>, <link> are self-closing.",
170
+ severity='error'
171
+ ))
172
+
125
173
  def _check_performance(self, node: Dict[str, Any]):
126
174
  """Check for performance anti-patterns"""
127
175
  attrs = node.get('attributes', {})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: htmlxify
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: htmlxify - A simplified web markup language compiler that transpiles to HTML, CSS, and JavaScript
5
5
  Home-page: https://github.com/Aquib489/htmlxify
6
6
  Author: Aquib489
@@ -134,6 +134,9 @@ HTMLXIFY page.HTMLXIFY output/
134
134
  - ✅ **XSS Protection** - Automatic HTML escaping for security
135
135
  - ✅ **Fast Compilation** - Single-pass compiler, instant results
136
136
  - ✅ **Production Ready** - Generates clean, optimized code
137
+ - ✅ **Void Elements** - Proper `<br>`, `<img>`, `<input>`, `<meta>`, etc. handling
138
+ - ✅ **Escape Sequences** - Support for `/{`, `/}`, `/(`, `/)`
139
+ - ✅ **Boolean Attributes** - HTML5 booleans like `disabled`, `checked`, `required`
137
140
 
138
141
  ## 📋 Implementation Status
139
142
 
@@ -221,7 +224,9 @@ This generates:
221
224
 
222
225
  Open `output/hello.html` in your browser and you're done! 🎉
223
226
 
224
- **That's it!** No configuration, no build tools. Just HTML, CSS, and JS.## 📖 Language Syntax Guide
227
+ **That's it!** No configuration, no build tools. Just HTML, CSS, and JS.
228
+
229
+ ## 📖 Language Syntax Guide
225
230
 
226
231
  ### Basic Elements
227
232
 
@@ -231,6 +236,12 @@ div { Content }
231
236
  p { Paragraph }
232
237
  h1 { Heading }
233
238
  button { Click Me }
239
+
240
+ // Void elements (no closing tag)
241
+ br
242
+ img(src: "photo.jpg", alt: "Photo")
243
+ input(type: "text")
244
+ meta(charset: "UTF-8")
234
245
  ```
235
246
 
236
247
  ### Classes & IDs
@@ -252,14 +263,30 @@ div.card#featured { ... }
252
263
  ### Attributes
253
264
 
254
265
  ```markup
255
- // Simple attributes
266
+ // String attributes
256
267
  button(onclick: "handleClick") { Click }
268
+ a(href: "https://example.com", target: "_blank") { Link }
257
269
 
258
- // Multiple attributes
259
- input(type: "email", placeholder: "Enter email", required: true)
270
+ // Boolean attributes (no value)
271
+ input(type: "checkbox", checked)
272
+ input(type: "text", disabled)
273
+ button(disabled) { Can't Click }
274
+ form(novalidate) { ... }
275
+ ```
260
276
 
261
- // String values
262
- a(href: "https://example.com", target: "_blank") { Link }
277
+ ### Escape Sequences
278
+
279
+ When you need characters that conflict with syntax, use escape sequences:
280
+
281
+ ```markup
282
+ // Escaped curly braces
283
+ p { JSON: /{ "key": "value" /} }
284
+
285
+ // Escaped parentheses
286
+ code { function/(/)/() /{ return true; /} }
287
+
288
+ // Real-world example
289
+ p { Price: $99.99 (50% off) and formula: x^2 }
263
290
  ```
264
291
 
265
292
  ### Nesting
@@ -12,7 +12,7 @@ long_description = readme.read_text(encoding='utf-8') if readme.exists() else ''
12
12
 
13
13
  setup(
14
14
  name='htmlxify',
15
- version='1.0.0',
15
+ version='1.0.1',
16
16
  description='htmlxify - A simplified web markup language compiler that transpiles to HTML, CSS, and JavaScript',
17
17
  long_description=long_description,
18
18
  long_description_content_type='text/markdown',
File without changes
File without changes
File without changes