Skip to content

SICPy: playground-link construction is JS/Source-specific (chap=/variant=/prgrm=) #1219

Description

@martin-henz

Tracking a language idiosyncrasy in the build that the language-axis refactor's tag-threading does not cover, found while reviewing #1217.

Context

We are generalizing the build so it can produce a Python edition ("SICPy", from xml_py/) alongside the JavaScript edition ("SICP JS"), sharing one tooling codebase, via a language descriptor in javascript/editions.ts.

Most JS-specifics are just XML tag names (JAVASCRIPT*), handled by the descriptor. Two surface strings — the line-comment marker (//) and the edition title (SICP JS) — are now also in the descriptor (commentPrefix, displayName; Python: #, SICPy), done in #1217.

The remaining idiosyncrasy: the Source Academy playground link

Each runnable snippet is turned into a "open in playground" link whose program is compressed into the URL with Source-JavaScript-specific parameters:

chap=<1..4>&variant=<...>&prgrm=<compressed program>

Sites:

  • processSnippetJson.js (chap= + &prgrm=, the implicit_chap === "5" ? "4" remap)
  • processSnippetHtml.js (/playground#chap=...&prgrm=...)
  • processSnippetPdf.js (/playground\#chap=...&prgrm=...)
  • processSnippetJs.js (chapter=/variant= annotation)

chap=1..4 selects the Source §1–4 sublanguage levels, which are specific to the JavaScript editions. Source Academy runs Python differently (it is not selected via chap=1..4), so this is not a simple string swap — it needs a per-language playground-link strategy.

What's needed

  • Decide how SICPy snippets should link into the playground (which URL scheme / language selector Source Academy's Python mode uses).
  • Add the necessary fields/among the language descriptor (e.g. a playgroundLink(program, chap, variant) builder, or a playgroundLanguage parameter) and route the four sites through it.
  • Verify the JavaScript edition output stays byte-identical (golden-diff harness).

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions