edit_html_file
Описание
Local static Python-based server and web UI for editing HTML
Языки
- JavaScript41,7%
- Python24,5%
- HTML23,8%
- CSS10%
HTML File Editor
A simple web-based HTML editor with live preview and tag formatting tools. This editor is designed for quick HTML editing with real-time preview in a split-pane interface.
Screenshots




Features
📋 Core Interface Features
- Split-pane interface: Left panel for HTML editing, right panel for live preview
- Resizable panels: Drag the vertical splitter (
) to adjust editor/preview widths (default 50/50 split)‖ - Status bar: Shows current file and operation status
- Clean, professional UI: No emojis or distracting icons - text-only interface
🏷️ HTML Tags & Structure Menu
The editor provides organized menu categories for inserting HTML tags:
Current Implementation
Basic Formatting Tags:
- Bold (B):
- Bold text<b>text</b> - Italic (I):
- Italic text<i>text</i> - Underline (U):
- Underlined text<u>text</u> - Paragraph (P):
- Paragraph block<p>text</p> - Div:
- Division/container<div>text</div> - Span:
- Inline container<span>text</span>
Planned/Upcoming Features
🔍 Find/Replace Menu
- Find: Search for substring using modal dialog
- Replace: Replace substring using modal dialog
↩️ Actions Menu
- Undo: Revert last change
- Redo: Reapply undone change
- Screen Keyboard: Show on-screen keyboard
- Insert Date: Insert current date/time
🏗️ Structure Tags Menu
- Main:
- Main content<main>content</main> - Section:
- Thematic grouping<section>content</section> - Article:
- Independent content<article>content</article> - Aside:
- Side content<aside>content</aside> - Header:
- Introductory content<header>content</header> - Footer:
- Closing content<footer>content</footer> - Nav:
- Navigation links<nav>links</nav> - Address:
- Contact information<address>contact</address>
📖 Definitions Submenu
- DL:
- Definition list<dl>definition list</dl> - DT:
- Definition term<dt>term</dt> - DD:
- Definition description<dd>definition</dd>
📝 Forms Menu
- Form:
- Input form<form>elements</form> - Input Text:
- Text field<input type="text"> - Input Password:
- Password field<input type="password"> - Checkbox:
- Checkbox<input type="checkbox"> - Radio:
- Radio button<input type="radio"> - Hidden Input:
- Hidden field<input type="hidden"> - Select:
- Dropdown list<select>options</select> - Option:
- Dropdown option<option>value</option> - Textarea:
- Multi-line text<textarea>content</textarea> - Output:
- Calculation result<output>result</output>
🎬 Media Content Menu
- Video:
- Video player<video>sources</video> - Video Source:
- Video source<source src="video.mp4"> - Audio:
- Audio player<audio>sources</audio> - Audio Source:
- Audio source<source src="audio.mp3">
📄 Meta Tags Menu
- Meta Description: <meta name="description" content="...">
- Meta Author: <meta name="author" content="...">
🛠️ Editor Features
- Syntax-aware editing: Monospace font with proper text wrapping
- Live preview: See HTML rendering in real-time as you type
- Auto-save on change: Content is saved to server automatically during editing
- Undo/Redo: Standard browser undo/redo functionality works
📁 File Operations
| Button | Function | Description |
|---|---|---|
| Save | Save File | Save current HTML to disk. Creates new file if none exists |
| Open | Open File | Open HTML file from local computer via file dialog |
| Clear | Clear Editor | Remove all content from editor (with confirmation) |
🌐 Preview Features
- Live rendering: Actual HTML/CSS/JavaScript execution in embedded browser
- Static asset support: Images, CSS, JS files load from current directory
- Automatic refresh: Preview updates on every keystroke
- Full browser context: Preview behaves like actual web page
⚙️ Technical Features
- No dependencies: Pure Python standard library only
- Cross-platform: Works on Windows, macOS, Linux
- Auto-port selection: Automatically finds available port (8080-8099)
- Command-line support: Open files directly from terminal
- Browser auto-launch: Opens editor in default web browser automatically
Installation
No installation required! This is a pure Python script with no external dependencies.
Requirements
- Python 3.6 or higher
- Modern web browser (Chrome, Firefox, Edge, Safari)
Usage
Basic usage
Using the Editor Interface
-
Panels Layout:
- Left Panel (HTML Source): Edit your HTML code here
- Right Panel (Live Preview): See rendered HTML output
- Splitter (
): Drag horizontally to resize panels‖
-
Toolbar Operations:
- File Operations: Save, Open, Clear
- Tag Formatting: B, I, U, P, DIV, SPAN buttons
- All changes are reflected immediately in the preview panel
-
Workflow:
- Type HTML in left panel → See results in right panel
- Select text → Click tag button → Text gets wrapped
- Save frequently with Save button or automatically
Tag Insertion Methods
- With selection: Select text → Click tag → Text gets wrapped
- Without selection: Click tag →
inserted at cursor<tag>text</tag> - Nested tags: Wrap already-tagged content with additional tags
Keyboard & Mouse Controls
- Text selection: Standard click/drag or Shift+arrow keys
- Tag insertion: Click buttons with or without text selected
- Panel resizing: Click and drag the splitter between panels
- File operations: Use toolbar buttons or browser's file dialog
Integration with entity_xml_crud_app
This editor is particularly useful for editing HTML templates in the ArtNazarov/entity_xml_crud_app project.
Editing Templates
Asset Loading
The preview automatically serves static files (CSS, JS, images) from the HTML file's directory, making it perfect for:
- Template development with linked stylesheets
- Testing image paths and relative URLs
- Debugging JavaScript functionality
- Previewing responsive designs
How It Works
Architecture
Terminal Command → Python Script → Local HTTP Server → Browser Editor
↓ ↓ ↓ ↓
File path Content loading Port 8080 User Interface
↓ ↓ ↓ ↓
HTML file ←─── File System ←── Auto-save ←── User edits
Server Details
The editor runs a local HTTP server that:
- Serves the editor interface at http://localhost:8080
- Handles file operations (open/save)
- Manages content updates between editor and preview
- Supports static file serving for preview assets
Roadmap & Planned Features
Phase 1: Core Editor (Current)
- ✓ Split-pane interface with resizable panels
- ✓ Basic tag formatting (B, I, U, P, DIV, SPAN)
- ✓ File operations (Open, Save, Clear)
- ✓ Live preview with static asset support
Phase 2: Enhanced Features (Planned)
- 🔄 Find/Replace functionality
- 🔄 Undo/Redo operations
- 🔄 Structured tag menus (Forms, Media, Meta tags)
- 🔄 Screen keyboard and date insertion
Phase 3: Advanced Features (Future)
- 🔲 Syntax highlighting
- 🔲 Code validation
- 🔲 Multiple file tabs
- 🔲 Export to PDF/Word
- 🔲 Template library
Troubleshooting
Common Issues & Solutions
| Issue | Solution |
|---|---|
| Port already in use | Script auto-tries ports 8080-8099. Close conflicting apps or wait |
| Images/CSS not loading | Ensure asset files are in same directory or use correct relative paths |
| Browser doesn't open | Manually navigate to (or shown port) |
| File save fails | Check write permissions in target directory |
| Preview not updating | Ensure auto-refresh is working; try manual edit to trigger update |
| Tag buttons not working | Make sure text is selected or cursor is placed in editor |
Port Conflicts
If you see "Address already in use", the script will automatically try the next port. Check terminal output for the actual port number.
Static File Issues
For proper asset loading in preview:
- Keep images in same directory as HTML file
- Use relative paths: <img src="image.jpg">
- External URLs work normally: <img src="https://...">
Stopping the Editor
- Normal shutdown: Press Ctrl+C in the terminal
- Force quit: Close terminal or kill Python process
- Browser: Simply close the browser tab/window
Project Structure
edit_html_file/
├── edit_html_file.py # Main editor script (single file!)
├── README.md # This documentation
└── (no dependencies, no installation needed)
Development Notes
Single File Design
The entire editor is contained in one Python file for maximum portability:
- No package management required
- Easy to distribute and share
- Simple to understand and modify
Extensibility
The modular design allows for easy addition of:
- New tag buttons and menu categories
- Additional file formats
- Custom themes/styles
- Enhanced preview features
License
Open source - free to use, modify, and distribute.
Related Projects
- ArtNazarov/entity_xml_crud_app - Ideal companion for HTML template development
- Perfect for web development students, template designers, and quick HTML prototyping
Version History
- v1.0: Initial release with split-pane editor, basic tag buttons, live preview
- v1.1: Added static file serving, improved UI, bug fixes
- v1.2: Planned - Find/Replace, Undo/Redo, expanded tag menus
Quick Start Checklist
- Python 3.6+ installed
- Download edit_html_file.py
- Run: python3 edit_html_file.py
- Edit HTML in left panel
- See live preview in right panel
- Use tag buttons for quick formatting
- Save your work frequently
Perfect for: Quick HTML edits, template development, learning HTML, prototyping, or testing web snippets with immediate visual feedback!