A powerful Streamlit-based content creation and editing tool for creating beautifully formatted markdown content, especially optimized for WeChat publishing.
- Z-Image-Turbo + ModelScope: New AI image providers with API key support
- Image Ratio Control: 1:1, 16:9, 9:16 for AI, Picsum, and Placeholder
- Daily Quotas: Built-in limits for AI image generation
- Auto-Render: Preview updates automatically when Image Source changes
- Generate Titles: Displays persistently below button with copy functionality
- Smart Format: Better error handling and detailed logging
- Expand Content: Improved error reporting with debug info
- Suggest Components: Insert components with one click
- Polish with Context: Conservative mode preserves original format
- Fixed Ollama Integration:
- Now actually fetches models from local Ollama instance
- Better connection checking with specific error messages
- Normalized engine name detection
- 60-second timeout for local models
- Fixed NameError: context_text not defined
- Removed empty div elements from DOM
- Fixed sidebar spacing (gap:0 no longer affects sidebar)
- Better session state initialization
- Comprehensive error logging for debugging
- 📝 Rich Markdown Editor - Create content with markdown syntax and custom components
- 🎨 Theme Support - Multiple beautiful themes for different content styles
- 📄 PDF Export - Export your content as PDF with professional styling
- 🤖 AI Integration - AI-powered content polishing, formatting, and suggestions
- 🖼️ Image Library - Manage and reuse images across projects
- 📚 Template Library - Pre-built templates for common content types
- 🔌 Plugin System - Extend functionality with custom plugins
- 📱 WeChat Optimized - Content optimized for WeChat publishing
- 💾 Auto-save - Never lose your work with automatic saving
- 🔄 Version History - Track changes and restore previous versions
- 🌈 Beautiful Gradients - 8 stunning gradient styles for image placeholders
- 📐 Pattern Backgrounds - Real SVG-based patterns (dots, lines) for visual appeal
- Python 3.8 or higher
- pip (Python package manager)
-
Clone or download this repository
-
Install dependencies:
pip install -r requirements.txt- Run the application:
streamlit run app.pyThe application will open in your default web browser at http://localhost:8501
MarkPolish Studio/
├── app.py # Main application (UI and orchestration)
├── config.py # Configuration, templates, and setup
├── file_operations.py # File save/load, version history, auto-save
├── pdf_generator.py # PDF generation functionality
├── image_handling.py # Image processing and library management
├── ai_integration.py # AI/OpenAI integration
├── content_processing.py # Content parsing, markdown processing, preview
├── ui_helpers.py # UI utility functions
├── components.py # Markdown component system
├── z_image.py # Z-Image-Turbo (DashScope) AI image client
├── themes.py # Theme definitions
├── error_handler.py # Error handling utilities
├── performance.py # Performance optimization
├── plugin_system.py # Plugin system
├── keyboard_listener.py # Keyboard shortcuts
├── migration_tool.py # Migration utilities
├── requirements.txt # Python dependencies
├── plugins/ # Custom plugins directory
│ ├── example_callout.py
│ └── README.md
└── projects/ # Project files directory
└── images/ # Image library
- Create a virtualenv:
python -m venv venv && source venv/bin/activate - Install deps:
pip install -r requirements.txt - Run:
streamlit run app.py - Configure AI in the sidebar (OpenRouter or Ollama); leave as “None” to disable AI.
- Autosave is on; use 💾 Force Save Now for a manual backup.
- 创建虚拟环境:
python -m venv venv && source venv/bin/activate - 安装依赖:
pip install -r requirements.txt - 运行:
streamlit run app.py - 在侧边栏配置 AI(OpenRouter 或本地 Ollama);若不使用 AI 可保持 “None”。
- 自动保存始终开启;需要手动备份时点 💾 立即强制保存。
- Start a New Project: Click "New Project" in the sidebar
- Use Templates: Select a template from the Templates tab
- Edit Content: Use the markdown editor to create your content
- Preview: See a live preview of your content
- Save: Save your project with a name
MarkPolish Studio supports custom markdown components:
::: hero- Hero sections with centered content::: col-2- Two-column layout::: col-3- Three-column layout::: steps- Step-by-step instructions::: timeline- Timeline visualization::: card- Styled card components[IMG: description]- AI-generated images[LOCAL: filename]- Local images<video src="https://example.com/video.mp4" controls style="width:100%;height:auto;display:block;"></video>- Responsive raw video embed (HTML)::: video src="https://example.com/video.mp4" poster="" caption="" autoplay=false muted=false loop=false :::- Video component (HTML player; WeChat may ignore inline playback)
Choose from multiple themes optimized for different content types:
- Apple Minimalist
- Nordic Frost
- Dark Mode
- And more...
- Ollama (Local) - Run AI models locally with full privacy
- OpenAI - GPT-4o, GPT-4o-mini, GPT-4-turbo, GPT-3.5-turbo
- OpenRouter - Access to multiple AI models through single API
- Gemini - Google's AI models
- Anthropic - Claude models
- DeepSeek - Cost-effective AI models
- 💡 Generate Titles: Generate catchy, punchy titles for your content (persists below button with copy functionality)
- 📈 Expand Content: Add more detail, examples, and context to your content
- ✨ Smart Format: Improve structure and formatting while preserving content
- 💡 Suggest Components: Get AI suggestions for markdown components to enhance layout
- 🧠 Polish with Context: Refine content using optional context notes (conservative mode preserves original format)
- Ollama: Ensure Ollama is running locally (http://localhost:11434). Click "Fetch Models" to load available models.
- Cloud Providers: Enter your API key in the sidebar. Keys are session-only by default for security.
- Error Debugging: AI actions now show detailed error messages with engine, model, and URL info for troubleshooting.
Choose from multiple image sources. AI providers need API keys in Secrets (Cloud) or .env (local).
- Z-Image-Turbo (AI) (default) - AI images via DashScope; set
DASHSCOPE_API_KEY - ModelScope (AI) - AI images via 魔搭 (higher free quota); set
MODELSCOPE_API_KEYfrom modelscope.cn/my/myaccesstoken - Picsum (Stock) - Random high-quality stock photos
- Placeholder (Text) - Text placeholders for layout planning
- Gradients (8 styles) - Beautiful CSS gradients: Blue, Purple, Sunset, Ocean, Forest, Aurora, Fire, Midnight
- Patterns - Real SVG-based patterns: Dots, Lines
- HTML Export: Export as clean HTML or copy HTML code
- PDF Export: Export as PDF (requires PDF library)
- WeChat Format: Optimized for WeChat publishing
- File load/delete/history buttons work; file info shows; saving creates/updates the file.
- AI engine set → each AI action runs; buttons disable while running; toasts/spinners show; output updates.
- Empty编辑器/Editor empty → AI actions show “Please add text” toast; no spinner/no crash.
- Rapid double-click on AI buttons is debounced; “another action running” toast appears if busy.
- Language toggle EN/中文 keeps AI config (engine/key/model) unchanged.
- “Suggest Components” returns buttons; insert works and toasts appear; clear suggestions works.
- Force Save works when a filename is provided; autosave still functions.
streamlit- Web frameworkmarkdown- Markdown processingPillow- Image processingrequests- HTTP requests
openai- AI integrationreportlab- PDF generation (recommended)weasyprint- Alternative PDF generationxhtml2pdf- Alternative PDF generationpdfkit- Alternative PDF generation (requires wkhtmltopdf)
Configure AI settings in the sidebar using the new Provider Manager:
- Provider Selection: Choose from Ollama (local), OpenAI, OpenRouter, Gemini, Anthropic, or DeepSeek
- API Host: Enter the API endpoint URL
- API Key: Enter your API key (stored securely with configurable security levels)
- Model Selection: Choose from available models (click "Fetch Models" to load from provider)
- Security Options: Choose security level for API key storage:
- Session Only (Level 1): Key lost when browser closes
- Encrypted Local (Level 2): Key stored encrypted on disk
- Never Save (Level 0, default for cloud): Key never persisted
Choose from multiple image sources for your content. Set API keys in Streamlit Secrets (Cloud) or in a .env file (local).
- Z-Image-Turbo (AI) (default) - AI images via DashScope; requires
DASHSCOPE_API_KEY - ModelScope (AI) - AI images via 魔搭 ModelScope (e.g. higher free quota); requires
MODELSCOPE_API_KEYfrom modelscope.cn/my/myaccesstoken - Picsum (Stock) - Random high-quality stock photos
- Placeholder (Text) - Text placeholders for layout planning
- Gradients (8 styles) - Beautiful CSS gradients:
- Gradient (Blue) - Blue to purple gradient
- Gradient (Purple) - Purple gradient
- Gradient (Sunset) - Orange to red gradient
- Gradient (Ocean) - Cyan to blue gradient
- Gradient (Forest) - Green gradient
- Gradient (Aurora) - Aurora borealis style
- Gradient (Fire) - Red to yellow gradient
- Gradient (Midnight) - Dark blue gradient
- Patterns - Real SVG-based patterns:
- Pattern (Dots) - Polka dots pattern on grey background
- Pattern (Lines) - Diagonal lines pattern on grey background
Aspect ratio is selectable (1:1, 16:9, 9:16) for AI images, Picsum, and Placeholder.
Image API keys (ModelScope 魔搭): To use ModelScope (AI) (魔搭), get your token from modelscope.cn/my/myaccesstoken, then set MODELSCOPE_API_KEY in Streamlit Secrets (Cloud) or in a .env file (local), e.g. MODELSCOPE_API_KEY=your-token. No extra config on the ModelScope website is required.
Install at least one PDF library:
pip install reportlab # Recommended (pure Python, no system deps)Create custom plugins by:
- Copy
plugins/example_callout.pyas a template - Modify the
PLUGIN_METADATAdictionary - Implement the
render()function - Save in the
plugins/directory - Restart MarkPolish Studio
See plugins/README.md for detailed plugin documentation.
- Install a PDF library:
pip install reportlab - Check error messages in the UI
- Install OpenAI:
pip install openai - Check API key configuration
- Verify network connection
- For Ollama users:
- Ensure Ollama is running:
ollama serve - Check Ollama URL is correct (default: http://localhost:11434/v1)
- Click "Test Connection" to verify Ollama is accessible
- Click "Fetch Models" to load available local models
- Check browser console for specific error messages (engine, model, URL shown in UI)
- Ensure Ollama is running:
- Common errors:
- "NameError: context_text" - Fixed in V1.1
- "Ollama models not fetching" - Fixed in V1.1 (now actually fetches from API)
- "Connection Failed" - Check Ollama is running locally
- Check image file paths
- Ensure images are in
projects/images/directory - Check file permissions
The codebase is organized into modules:
- app.py: Main UI and orchestration
- ai_provider_manager.py: NEW - Multi-provider AI management with secure key storage
- ai_integration.py: AI features with Ollama fixes and improved prompts
- content_processing.py: Content processing
- file_operations.py: File management
- pdf_generator.py: PDF generation
- image_handling.py: Image operations
- config.py: Configuration and constants
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License
Copyright (c) 2024-2026 MarkPolish Studio contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For issues, questions, or contributions, please [add your support contact information].
MarkPolish Studio V1.1 - Content Ops Edition (AI & UI Improvements)