Skip to main content
Chemistry LibreTexts

7.2: Setting Up the PG Renderer

  • Page ID
    555732
  • ​

    ​

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \(\newcommand{\longvect}{\overrightarrow}\)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\ket}[1]{\left| #1 \right>}\)
    \(\newcommand{\bra}[1]{\left< #1 \right|}\)
    \(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
    \(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
    \(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
    \(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
    \(\newcommand{\expect}[1]{\langle #1 \rangle}\)
    \(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Use this section when you are setting up local rendering for the first time or returning after a break. The goal is to get one problem rendering in your browser so you have a fast feedback loop for editing and debugging.

    Think of local rendering like setting up a bench assay. Before you run a full experiment, you confirm that your reagents work, your equipment reads correctly, and you can reproduce a known result. Here, the reagent is your .pg file, the equipment is the renderer container, and the known result is a cleanly rendered problem with visible answer blanks. Once this baseline works, every edit you make is a single-variable change from a known-good state.

    What you need

    • Podman or Docker installed on your machine
    • A folder containing your .pg files (see PG Problem Files for PG file structure)
    • A terminal (command prompt) for running commands
    • A web browser for viewing rendered problems

    Start the renderer

    The renderer runs inside a container. Start it from your terminal with one of these commands, depending on which container tool you have installed.

    1. Start the container:
      podman compose up -d
      or
      docker compose up -d
    2. Check that it is running. Open a terminal and run:
      curl http://localhost:3000/health
      You should see {"status":"ok"} in the output.
    3. If you see "connection refused", the container is not running yet. Wait a few seconds and try again. The renderer can take 10 to 30 seconds to finish starting up.

    What working looks like vs what broken looks like

    What working looks like vs what broken looks like reference.
    What you see What it means What to do
    The /health endpoint returns {"status":"ok"} The renderer is running and ready. Proceed to the browser editor.
    The browser editor at http://localhost:3000 loads and rendering a simple problem shows formatted text with answer blanks Everything is working end to end. You are ready to start editing problems.
    "Connection refused" in the terminal The container is not running. Wait a few seconds and try the health check again. If it still fails, check that the container started without errors.
    A blank page or error page in the browser The renderer started but something else is wrong. Check the container logs for error messages.

    Open the browser editor

    1. Open http://localhost:3000 in your browser.
    2. Load a .pg file from the private/ folder (see Full file for a full file example).
    3. Set a seed number. Start with something simple like 1234.
    4. Click Render.

    The rendered output should show formatted text, any math expressions, and answer blanks where students would type or select their answers. If you see raw PGML markup or error text instead, something needs to be fixed. Common Mistakes and How to Fix Them covers the most common causes.

    Private folder workflow

    Place your .pg files inside the private/ folder that is mounted into the renderer container. The web editor can then load files directly using the path private/yourfile.pg.

    Changes you save to files on your computer appear in the container automatically. There is no separate upload or sync step. Edit the file in your text editor, save it, then click Render in the browser to see the updated output.

    The one rule that saves hours

    When debugging, write down (1) the file path and (2) the seed. Do not change either until the failure is fixed. Change one thing at a time.

    This is the same principle as a controlled experiment. If you change the seed and the code at the same time, you cannot tell which change caused the new behavior. Lock the seed, fix the code, and only move on to testing other seeds after the current one renders correctly.

    What to record while you work

    What to record while you work: record, example, and why it matters.
    Record Example Why it matters
    File path private/enzyme_kinetics.pg Keeps your failing case tied to one file.
    Seed 1234 Locks the random variant for reproducibility.
    What you changed "Changed units from mM to micromolar" Makes debugging traceable when you need to undo a change.

    Your first render checklist

    1. Start the renderer container.
    2. Check /health returns {"status":"ok"}.
    3. Open your browser to http://localhost:3000.
    4. Load a .pg file from private/.
    5. Set the seed to 1234.
    6. Click Render.
    7. Read the output like a student would.
    8. Confirm answer blanks appear where expected.

    HTML render is the primary test

    WeBWorK questions are designed for browsers. The rendered HTML page is the most important test of whether your problem works correctly. Open it in a browser and check that the question looks right visually: text is formatted, math displays properly, answer blanks are in the right places, and interactive widgets (radio buttons, dropdowns) appear as expected instead of plain text boxes.

    Static linting and code review are useful supporting checks, but they cannot replace the rendered output. A problem that passes every lint check can still display poorly or confuse students. Always finish by reading the rendered page as a student would read it.

    Apply it today

    • Use local rendering for the tight edit-preview loop: edit your file, save, click Render, and check the output. This cycle should take seconds, not minutes.
    • Once the local render looks right, use ADAPT for the final publish workflow. Local rendering confirms the code works; ADAPT confirms the assignment context and student view.

    This page titled 7.2: Setting Up the PG Renderer was last modified on Fri, 27 Feb 2026 15:41:00 GMT and is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Neil R. Voss.