Script: one routine for the headless browser

Abierto
#3,247 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
40/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python
Área
tooling

Línea de trabajo

Start by comparing the Playwright setup in preview_images(), mom_static_problems() and epub() in pretext/lib/pretext.py: the import check, asyncio loop, browser launch, page capture and close. Decide with a maintainer where the shared helper should live, since the issue suggests pretext/lib/common.py but leaves it open. Done means all three callers use one routine, a missing Playwright is reported once, and MyOpenMath starts one browser for all its SVGs.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

PreTeXt now drives Playwright's headless Chromium in three places in pretext/lib/pretext.py. Each has its own copy of the same setup: import the module (with a message if it is missing), run an asyncio loop, launch Chromium, open a page, capture it, and close.

  • preview_images() takes screenshots of interactive elements served from a local web server, reusing one page for all of them.
  • mom_static_problems() turns each MyOpenMath SVG into a PDF and a PNG, launching a new browser for every SVG.
  • epub() takes a picture of the EPUB's cover page for its default cover image (#3239).

A single routine, perhaps in pretext/lib/common.py, could start Chromium, capture a page or a string of HTML at a given size and scale, and report once when Playwright or its browser is missing. The cover and MyOpenMath would use it directly, and MyOpenMath would then start one browser for all its SVGs instead of one each. preview_images() could share the browser start-up.

Claude Opus 5.5, acting as a coding assistant for Rob Beezer

Lenguaje dominante
XSLT
Estrellas
466
Forks
251
Merge medio
4 min
PR fusionados (30 d)
13

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PreTeXtBook/pretext

Todos los issues de PreTeXtBook/pretext

Issues similares

Más issues de DevTools

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.