Skip to content

Add RTL text plugin support and responsive HTML export#159

Open
yharby wants to merge 2 commits intoeoda-dev:mainfrom
yharby:feature/rtl-text-plugin
Open

Add RTL text plugin support and responsive HTML export#159
yharby wants to merge 2 commits intoeoda-dev:mainfrom
yharby:feature/rtl-text-plugin

Conversation

@yharby
Copy link

@yharby yharby commented Feb 1, 2026

Summary

This PR adds support for the MapLibre RTL text plugin to enable proper rendering of right-to-left languages (Arabic, Hebrew, etc.) and makes HTML export responsive by default.

Changes

RTL Text Plugin Support

  • Bundle mapbox-gl-rtl-text.js for offline RTL text rendering
  • Initialize RTL plugin automatically in all environments:
    • ✅ Standalone HTML (Map.to_html(), Map.save())
    • ✅ Jupyter notebooks (MapWidget)
    • ✅ Marimo notebooks
    • ✅ Shiny apps
  • Lazy loading: plugin only activates when RTL text is encountered
  • Safe initialization with error handling

Responsive HTML Export

  • Maps now fill the viewport by default (100% width/height)
  • Proper HTML structure with <head> section
  • Users can still override with custom style parameter

Files Changed

  • maplibre/_templates.py - RTL init + responsive HTML template
  • maplibre/map.py - Load RTL plugin in to_html()
  • maplibre/srcjs/pywidget.js - Updated bundle with RTL support
  • maplibre/srcjs/ipywidget.js - Updated bundle with RTL support
  • maplibre/srcjs/mapbox-gl-rtl-text.js - Bundled RTL plugin
  • tests/test_map.py - Added RTL test
  • examples/rtl_text_example.py - Visual test for standalone HTML
  • examples/rtl_test_marimo.py - Visual test for Marimo
  • examples/rtl_test_shiny.py - Visual test for Shiny

Related

Test Plan

  • uv run pytest - All tests pass
  • Standalone HTML - Arabic text renders correctly
  • Jupyter notebook - Arabic text renders correctly
  • Marimo notebook - Arabic text renders correctly
  • Shiny app - Arabic text renders correctly

- Bundle mapbox-gl-rtl-text.js for offline RTL text rendering
- Patch pywidget.js to expose maplibregl globally
- Initialize RTL plugin automatically in to_html()
- Make HTML export responsive (fullscreen by default)
- Add RTL text example and test

Closes eoda-dev#157, Closes eoda-dev#158
Update ipywidget.js and pywidget.js bundles from maplibre-bindings
with RTL text plugin support for all environments:
- Jupyter notebooks (MapWidget)
- Marimo notebooks
- Shiny apps

Features:
- RTL plugin bundled for OFFLINE usage (no CDN dependency)
- Lazy loading: plugin only activates when RTL text is encountered
- Safe initialization with error handling
- maplibregl exposed globally for compatibility

Add test examples for Marimo and Shiny.

Related: eoda-dev/maplibre-bindings#4
yharby added a commit to yharby/maplibre-bindings that referenced this pull request Feb 1, 2026
Initialize maplibregl.setRTLTextPlugin() in both bundles:
- ipywidget.js (for Jupyter/Marimo via anywidget)
- pymaplibregl.js (for Shiny and standalone HTML)

Changes:
- Import maplibre-gl in pymaplibregl.js and expose globally
- Bundle RTL plugin source for OFFLINE usage (no CDN dependency)
- Create blob URL from bundled plugin source
- Safe initialization with error handling

The RTL plugin (~150KB) is now bundled directly, enabling:
- Offline usage without internet connection
- No external CDN dependencies
- Consistent behavior across all environments

Closes eoda-dev#4
Related: eoda-dev/py-maplibregl#157, eoda-dev/py-maplibregl#159
@yharby yharby force-pushed the feature/rtl-text-plugin branch from af645b5 to 7b8afdf Compare February 1, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make exported HTML maps responsive by default Add RTL (Right-to-Left) text plugin support

1 participant