Andros Fenollosa 49f9e1d45f Fix source block rendering in preview cards
Source blocks (#+BEGIN_SRC / #+END_SRC) were not rendering correctly
in preview cards. The content was being displayed as raw Org Mode syntax
instead of formatted code blocks.

This fix:
- Detects source blocks using regex pattern matching
- Extracts code content and language identifier
- HTML-escapes code content to prevent XSS
- Replaces blocks with placeholders before other formatting
- Restores blocks as styled <pre><code> elements after line break conversion

Fixes issue where comments and code in source blocks were invisible
in share preview links.
2025-11-01 11:40:50 +01:00
2025-09-15 01:53:50 +02:00
2025-09-15 08:58:54 +02:00
2025-09-15 09:04:43 +02:00
2025-09-15 09:04:43 +02:00
2025-10-05 12:13:16 +02:00
2025-09-14 10:36:19 +02:00
2025-09-15 08:45:24 +02:00
2025-09-15 08:45:24 +02:00

Org Social Static Preview Generator

Tool for generating HTML previews from Org Social files. This tool creates social media-like preview cards for each post in your social.org file.

Screenshot

Link

Installation

No external dependencies required beyond Python 3 standard library and Jinja2:

pip install jinja2

Usage

Docker

Using Docker Compose (recommended):

# Create preview directory first
mkdir -p preview

# Copy `social.org` file to the current directory
cp /path/to/your/social.org .

# Run with Docker Compose
UID=$(id -u) GID=$(id -g) docker compose up

Or build and run manually:

# Create preview directory first
mkdir -p preview

docker build -t org-social-preview .
docker run -v $(pwd)/social.org:/app/social.org:ro -v $(pwd)/preview:/app/preview org-social-preview

Note: Make sure to create the preview directory before running Docker to avoid permission issues.

Arguments

  • --social-file, -s: Path to your social.org file (default: social.org)
  • --preview-dir, -p: Directory to save HTML previews (default: preview)
  • --template-dir, -td: Directory containing the template file (default: .)
  • --template-name, -tn: Template filename (default: template.html)

Local Python

Basic usage:

python org_social_preview_generator.py

With custom options:

python org_social_preview_generator.py --social-file my-social.org --preview-dir output --template-dir templates --template-name custom.html

File Structure

org-social-preview/
├── org_social_preview_generator.py  # Main script
├── template.html                   # HTML template
├── social.org                     # Your Org Social file
└── preview/                       # Generated HTML files
    ├── 2025-08-14T09-11-00plus0200.html
    ├── 2025-08-14T14-29-00plus0200.html
    └── ...

Template Customization

The HTML template (template.html) uses Jinja2 templating. You can customize:

  • Styling and layout
  • Open Graph metadata
  • Post display format
  • Color scheme and fonts

Available template variables:

  • nick: User nickname
  • formatted_content: Processed post content
  • mood: Post mood emoji
  • tags: List of tags
  • formatted_time: Formatted timestamp
  • avatar_url: User avatar URL
  • post_url: Post permalink

Technical recommendation

If you are going to use a cron job to generate them repeatedly, check the header or metadata for when the last modification was made.

License

This project is open source. See the main Org Social repository for more information.

Languages
Python 68.9%
HTML 26.6%
Dockerfile 2.7%
Shell 1.8%