htmlxify - A simplified web markup language compiler that transpiles to HTML, CSS, and JavaScript
Project description
HTMLXIFY - Web Markup Compiler
A complete, production-ready compiler for HTMLXIFY - a simplified web markup language that transpiles to clean HTML, CSS, and JavaScript with no configuration needed.
Write cleaner, faster markup. Build modern web pages in seconds.
๐ What is HTMLXIFY?
HTMLXIFY is a lightweight markup language designed to make web development faster and cleaner. Instead of writing verbose HTML, you write simple, intuitive markup that compiles to production-ready HTML, CSS, and JavaScript.
Before (Regular HTML):
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="app" class="container">
<h1 class="title">Welcome</h1>
<p class="subtitle">This is a paragraph</p>
<button class="primary" onclick="trackClick()">Click Me</button>
</div>
<script src="app.js"></script>
</body>
</html>
After (HTMLXIFY):
Write this in a file named page.HTMLXIFY:
html {
head {
meta(charset: "UTF-8")
meta(name: "viewport", content: "width=device-width, initial-scale=1.0")
title { My Page }
link(rel: "stylesheet", href: "page.css")
}
body {
div#app.container {
h1.title { Welcome }
p.subtitle { This is a paragraph }
button.primary(โก-call: "trackClick") { Click Me }
}
script(src: "page.js") { }
}
}
Then compile:
HTMLXIFY page.HTMLXIFY output/
Result: Identical output to the "Before" HTML code!
- All the boilerplate (doctype, html, head, meta tags) is generated automatically
- Responsive CSS is auto-generated (7+ KB)
- JavaScript handlers are auto-generated (10+ KB)
71% less code to write. Same semantic HTML output. Zero boilerplate.
โจ Key Features
- โ Simple Syntax - Intuitive markup language easy to learn
- โ No Configuration - Works out of the box with sensible defaults
- โ Auto-Generated CSS - Comprehensive stylesheet automatically created
- โ
API Integration - Built-in support for backend calls with
โก-call - โ
Dynamic Data Binding - Connect UI to data with
โก-data - โ Responsive Design - Mobile-first CSS with breakpoints
- โ XSS Protection - Automatic HTML escaping for security
- โ Fast Compilation - Single-pass compiler, instant results
- โ Production Ready - Generates clean, optimized code
- โ
Void Elements - Proper
<br>,<img>,<input>,<meta>, etc. handling - โ
Escape Sequences - Support for
/{,/},/(,/) - โ
Boolean Attributes - HTML5 booleans like
disabled,checked,required
๐ Implementation Status
| Feature | Status |
|---|---|
| Parser | โ Complete (13/13 tests passing) |
| HTML Generator | โ Complete (20+ KB output) |
| CSS Generator | โ Complete (7.3 KB with defaults) |
| JavaScript Generator | โ Complete (10.6 KB with API handlers) |
| CLI Tool | โ Complete & tested |
| Standalone Executable | โ Built for distribution (PyPI package) |
| Backend Integration | โ Complete (API calls with โก-call) |
| Semantic Validator | โ Complete |
| VS Code Extension | ๐ Planned |
| Language Server | ๐ Planned |
๐ Quick Start
Installation
Option 1: Install from TestPyPI (Recommended)
pip install -i https://test.pypi.org/simple/ HTMLXIFY
Then use the command:
HTMLXIFY myfile.HTMLXIFY output/
HTMLXIFY hello.HTMLXIFY output/ --verbose # With verbose output
HTMLXIFY --version # Check version
HTMLXIFY --help # View help
Option 2: Install from Source (For Development)
# 1. Install dependencies
pip install -r requirements.txt
# 2. Install package in development mode
pip install -e .
# 3. Use the command
HTMLXIFY myfile.HTMLXIFY output/
Option 3: Run Python CLI Directly
# 1. Install dependencies
pip install -r requirements.txt
# 2. Run the CLI
python cli.py myfile.HTMLXIFY output/
python cli.py hello.HTMLXIFY output/ --verbose # With verbose output
Your First HTMLXIFY File
Create a file named hello.HTMLXIFY:
div#app.container {
h1 { Hello World }
p { Welcome to HTMLXIFY }
}
Compile it:
# Using installed package (recommended)
HTMLXIFY hello.HTMLXIFY output/
# Or using Python directly
python cli.py hello.HTMLXIFY output/
This generates:
output/hello.html- Clean, semantic HTML (20+ KB)output/hello.css- Responsive stylesheet (7.3 KB)output/hello.js- JavaScript handlers (10.6 KB)output/hello.html.map- Source map for debugging
Open output/hello.html in your browser and you're done! ๐
That's it! No configuration, no build tools. Just HTML, CSS, and JS.
๐ Language Syntax Guide
Basic Elements
// Single elements
div { Content }
p { Paragraph }
h1 { Heading }
button { Click Me }
// Void elements (no closing tag)
br
img(src: "photo.jpg", alt: "Photo")
input(type: "text")
meta(charset: "UTF-8")
Classes & IDs
// Single class
div.container { ... }
// Multiple classes
button.primary.large { ... }
// IDs
div#main { ... }
// Classes and IDs together
div.card#featured { ... }
Attributes
// String attributes
button(onclick: "handleClick") { Click }
a(href: "https://example.com", target: "_blank") { Link }
// Boolean attributes (no value)
input(type: "checkbox", checked)
input(type: "text", disabled)
button(disabled) { Can't Click }
form(novalidate) { ... }
Escape Sequences
When you need characters that conflict with syntax, use escape sequences:
// Escaped curly braces
p { JSON: /{ "key": "value" /} }
// Escaped parentheses
code { function/(/)/() /{ return true; /} }
// Real-world example
p { Price: $99.99 (50% off) and formula: x^2 }
Nesting
div.container {
h1 { Title }
p { First paragraph }
p { Second paragraph }
button { Action }
}
Text Content
// Simple text
p { This is a paragraph }
// Multiple lines of text (preserved)
p {
This is a longer
paragraph spanning
multiple lines
}
// Mixed content (elements and text)
div {
h1 { Title }
This is text after heading
p { Another element }
}
๐ฅ Advanced Features
Backend Integration
button(โก-call: "selectPlan", data-plan: "starter") {
Select Plan
}
This generates:
- HTML:
<button data-api-call="selectPlan" data-plan="starter"> - JS: Auto-triggers mock API handler with sample response
Available endpoints with mock data:
trackCTAClick- CTA click trackingsubmitForm- Form submission handlerselectPlan- Plan selectioncontactSales- Sales inquirygetData- Generic data retrieval
Dynamic Data Binding
div(โก-data: "userData") {
p { User information }
}
In JavaScript, update it dynamically:
updateBinding('userData', 'new value');
Semantic HTML
header.navbar {
nav { Links }
}
main {
article.post { Content }
}
footer { Copyright }
Common Patterns
Navigation Bar
nav.navbar {
div.brand { Logo }
div.menu {
a(href: "/") { Home }
a(href: "/about") { About }
a(href: "/contact") { Contact }
}
}
Hero Section
div.hero {
h1.hero-title { Welcome }
p.hero-subtitle { Get started today }
button.cta(โก-call: "trackCTAClick") { Learn More }
}
Feature Grid
div.feature-grid {
div.feature-card {
h3 { Feature 1 }
p { Description }
}
div.feature-card {
h3 { Feature 2 }
p { Description }
}
div.feature-card {
h3 { Feature 3 }
p { Description }
}
}
Pricing Cards
div.pricing-grid {
div.pricing-card {
h3 { Starter }
p.price { $9/month }
button(โก-call: "selectPlan", data-plan: "starter") { Choose }
}
div.pricing-card.featured {
h3 { Pro }
p.price { $29/month }
button(โก-call: "selectPlan", data-plan: "pro") { Choose }
}
}
Comparison Table
table.comparison {
thead {
tr {
th { Feature }
th { Starter }
th { Pro }
}
}
tbody {
tr {
td { Users }
td { Up to 10 }
td { Unlimited }
}
}
}
๐ป CLI Usage
Basic Compilation
# Using executable (recommended - no Python needed)
HTMLXIFY.exe input.HTMLXIFY output/
HTMLXIFY.exe input.HTMLXIFY output/ --verbose
HTMLXIFY.exe --version
HTMLXIFY.exe --help
# Or using Python (if you prefer)
python cli.py input.HTMLXIFY output/
python cli.py input.HTMLXIFY output/ --verbose
python cli.py --version
python cli.py --help
Note: Both commands do exactly the same thing. The .exe is faster and doesn't require Python installed.
Output Files
For input file mypage.HTMLXIFY, the compiler generates:
output/
โโโ mypage.html # Semantic HTML structure
โโโ mypage.css # Responsive stylesheet (7+ KB)
โโโ mypage.js # JavaScript handlers & utilities
โโโ mypage.html.map # Source map for debugging
๐ Project Structure
HTMLXIFY/
โโโ HTMLXIFY/ # Main compiler package
โ โโโ cli.py # Command-line interface
โ โโโ parser/
โ โ โโโ grammar.lark # HTMLXIFY grammar
โ โ โโโ ast_builder.py # Parse tree to AST converter
โ โ โโโ indent_processor.py # Indentation hierarchy
โ โโโ generators/
โ โ โโโ html_gen.py # HTML output generator
โ โ โโโ css_gen.py # CSS output generator (650+ lines)
โ โ โโโ js_gen.py # JavaScript output generator
โ โโโ validator/
โ โ โโโ semantic.py # Semantic validation
โ โโโ utils/
โโโ tests/
โ โโโ unit/test_parser.py # 13 comprehensive tests
โโโ example.HTMLXIFY # Full feature demonstration
โโโ language_server/ # Future LSP support (planned)
โโโ dist/
โ โโโ HTMLXIFY.exe # Standalone executable (Windows)
โโโ build/
โ โโโ HTMLXIFY/ # Build directory with dependencies
โโโ example_backend.py # Example Flask backend
โโโ setup.py # Package configuration for PyPI
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
๐งช Testing
The compiler includes comprehensive tests:
# Run all tests
pytest tests/unit/test_parser.py -v
# Run specific test
pytest tests/unit/test_parser.py::test_basic_element -v
# Run with coverage report
pytest tests/unit/ --cov=HTMLXIFY --cov-report=html
Test Coverage:
- Basic elements (div, p, button, etc.)
- Classes (single and multiple)
- IDs
- Attributes
- Special attributes (โก-call, โก-data)
- Nesting and hierarchy
- Text content handling
- Mixed content (text + elements)
- Complex real-world structures
๐ Output Examples
Generated HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page</title>
<link rel="stylesheet" href="page.css">
</head>
<body>
<div id="app" class="container">
<h1 class="title">Hello World</h1>
<p>Welcome to HTMLXIFY</p>
</div>
<script src="page.js"></script>
</body>
</html>
Generated CSS (650+ lines of defaults)
/* Reset & Base Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto; }
/* Typography */
h1 { font-size: 2.5rem; font-weight: 600; }
h2 { font-size: 2rem; font-weight: 600; }
/* Responsive Design */
@media (max-width: 768px) {
.feature-grid { grid-template-columns: 1fr; }
body { font-size: 14px; }
}
/* And much more... */
Generated JavaScript
// Smart API URL Detection (4-level priority)
const API_BASE_URL = window.API_BASE_URL
|| (function() {
const meta = document.querySelector('meta[name="api-url"]');
if (meta) return meta.getAttribute('content');
if (window.location.hostname !== 'localhost') {
return '/api'; // Same domain backend
}
return 'http://localhost:5000/api'; // Local development
})();
// API Handlers (auto-wired to buttons with โก-call attribute)
const apiHandlers = {
'trackCTAClick': async function(element) { ... },
'selectPlan': async function(element) { ... },
'submitForm': async function(element) { ... },
// ... more handlers
};
// Data Bindings
const dataBindings = { ... };
// Animation Utilities
const animationUtils = { ... };
๐ฏ Real-World Examples
Complete Landing Page
nav.navbar {
div.brand { MyCompany }
div.nav-links {
a(href: "/") { Home }
a(href: "/features") { Features }
a(href: "/pricing") { Pricing }
}
}
div.hero {
h1 { Build Faster With HTMLXIFY }
p { Write 72% less code. Ship in days, not weeks. }
button.cta(โก-call: "trackCTAClick") { Get Started }
}
div.features {
div.feature-grid {
div.feature-card {
h3 { Fast }
p { Compiles in milliseconds }
}
div.feature-card {
h3 { Simple }
p { Intuitive syntax anyone can learn }
}
div.feature-card {
h3 { Powerful }
p { Generates production-ready code }
}
}
}
footer.footer {
p { Copyright 2025 }
}
๐ Security
The compiler includes built-in security features:
- XSS Prevention: All user content is HTML-escaped automatically
- Attribute Validation: Prevents malicious attribute values
- Safe Defaults: Strict mode for all generated code
- No Inline Scripts: All JavaScript is external and sandboxed
๐ Troubleshooting
Issue: "File not found" error
# Make sure file has .HTMLXIFY extension
python cli.py myfile.HTMLXIFY output/
# Make sure output directory exists or will be created
python cli.py input.HTMLXIFY ./dist/
Issue: Classes or IDs not styling
Make sure you're using the correct syntax:
// Correct
div.my-class { ... }
div#my-id { ... }
// Wrong (won't work)
div .my-class { ... }
div #my-id { ... }
Issue: Verbose mode not showing errors
Run with --verbose flag:
python cli.py input.HTMLXIFY output/ --verbose
๐ Learning Resources
- Start Simple: Try the Quick Start above
- Language Syntax: Read the syntax guide section
- Advanced Features: Explore โก-call and โก-data attributes
- Real Examples: Check
example.HTMLXIFYfor a complete demo - Test Suite: Review
tests/unit/test_parser.pyfor patterns
๐ Distribution & Deployment
Share the Executable
- Give users
HTMLXIFY.exefrom thedist/folder - Users can compile ANY
.HTMLXIFYfile with one command:HTMLXIFY.exe mysite.HTMLXIFY output/
- No Python installation, no dependencies, no configuration needed
Deploy Generated Files
- Compile your
.HTMLXIFYfile to get HTML, CSS, JS - Configure API URL (3 simple ways):
<!-- Option 1: Meta tag --> <meta name="api-url" content="https://api.yourdomain.com"> <!-- Option 2: Script variable --> <script>window.API_BASE_URL = 'https://api.yourdomain.com';</script> <!-- Option 3: Same domain (automatic) --> <!-- No configuration needed! Uses /api automatically -->
- Upload HTML, CSS, JS to any web server
- Done! Your site is live ๐
๐ฏ Next Steps
After installing and creating your first file:
- Create a portfolio page - Use feature cards and hero section
- Build a landing page - Try navbar, hero, features, pricing, footer
- Make it dynamic - Add โก-call endpoints for buttons
- Deploy to internet - Upload files and configure API URL
- Share the compiler - Give others
HTMLXIFY.exeto build their own sites
๐ก Tips & Tricks
Reusable Components
Create template files you can copy and modify:
// pricing-card.HTMLXIFY
div.pricing-card {
h3 { Plan Name }
p.price { $X/month }
ul {
li { Feature 1 }
li { Feature 2 }
}
button(โก-call: "selectPlan") { Choose }
}
Responsive Images
img(
src: "image.jpg",
alt: "Description",
loading: "lazy"
)
Form Patterns
form {
input(type: "email", placeholder: "Email", required: true)
input(type: "password", placeholder: "Password", required: true)
button(type: "submit") { Sign In }
}
๐ License
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
See the LICENSE file for the full license text and details.
๐ค Contributing
To contribute:
- Create a feature branch
- Write tests in
tests/unit/ - Submit a pull request
๐ Support
For questions or issues:
- Check the troubleshooting section above
- Review the example.HTMLXIFY example
- Check generated HTML/CSS/JS for clues
Happy markup writing! ๐
Made with โค๏ธ for faster web development
HTMLXIFY - Because simpler markup means faster development. ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file htmlxify-1.0.1.tar.gz.
File metadata
- Download URL: htmlxify-1.0.1.tar.gz
- Upload date:
- Size: 41.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47756428365512207d64457deca19d8782287497cbb4e4846e8f58033df1ceab
|
|
| MD5 |
6d62fd91d03590d1c9139d66bc875bb5
|
|
| BLAKE2b-256 |
6c90bc0c3fff362de43dc8b321e132509522a7c2ca2d5d6689ef4b7a439630bb
|
File details
Details for the file htmlxify-1.0.1-py3-none-any.whl.
File metadata
- Download URL: htmlxify-1.0.1-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f59a6f94b5b92cad287d7391259b9327288538853510a0b92d6bc800e33fd50
|
|
| MD5 |
c10544edcc242aabd59903aa4c0a9ba6
|
|
| BLAKE2b-256 |
113662e669f0d3ad1af9570da51f4805d76b15f153952374e254ee31dfb40ec5
|