diff --git a/CLAUDE.md b/CLAUDE.md
index f2d1ad3..1f0ed0f 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -17,7 +17,7 @@ npm run lint # oxlint; 7 known warnings, all in the vendored public/coi-servi
npm run test:browser # after a build: scripts/check-ide-browser.mjs, the IDE in headless Chrome
```
-The one automated check is `test:browser` (`scripts/check-ide-browser.mjs`): `playwright-core` drives the installed Chrome (GitHub's runner has one) against `vite preview` of `dist/`, with Pyodide from its CDN and its own fixtures (it serves a library by URL itself). It covers tab switches with a read-only file, per-tab projects, share links (library by URL, 404, cut and long links), ▶ and Tests, ⋮ «Info», and `input()` in the console (a recursive REPL, Stop → `EOFError`); add regression cases there. The browser's «leave the page» question and the iPad stay manual. `.github/workflows/ci.yml` runs `npm ci`, the build (tsc catches type changes in a new editor tag), lint and `test:browser` on every pull request. Pushes to `main` deploy to GitHub Pages (`deploy-pages.yml`). To check a change in the browser, use `npm run dev`; `npm run build && npm run preview` serves the production layout. The embed is a separate project site under the same origin, https://glpython-edu.github.io/glpython-editor/. The IDE's `coi-serviceworker.js` registers for scope `/`, which includes it, so after a change to that worker check the embed too: its demo page opened directly, and a LiaScript course.
+The one automated check is `test:browser` (`scripts/check-ide-browser.mjs`): `playwright-core` drives the installed Chrome (GitHub's runner has one) against `vite preview` of `dist/`, with Pyodide from its CDN and its own fixtures (it serves a library by URL itself). It covers tab switches with a read-only file, per-tab projects, share links (library by URL, 404, cut and long links), ▶ and Tests, ⋮ «Info», `input()` in the console (a recursive REPL, Stop → `EOFError`), and a task's instructions as a tab (`openFile`, a read-only `aufgabe.md` as a page, sanitizing); add regression cases there. The browser's «leave the page» question and the iPad stay manual. `.github/workflows/ci.yml` runs `npm ci`, the build (tsc catches type changes in a new editor tag), lint and `test:browser` on every pull request. Pushes to `main` deploy to GitHub Pages (`deploy-pages.yml`). To check a change in the browser, use `npm run dev`; `npm run build && npm run preview` serves the production layout. The embed is a separate project site under the same origin, https://glpython-edu.github.io/glpython-editor/. The IDE's `coi-serviceworker.js` registers for scope `/`, which includes it, so after a change to that worker check the embed too: its demo page opened directly, and a LiaScript course.
## Layout
@@ -25,7 +25,8 @@ The one automated check is `test:browser` (`scripts/check-ide-browser.mjs`): `pl
- `src/index.css` — the shell's styles (`ide-*` classes), from glpython-editor's `--glp-*` tokens. glpython-editor's `style.css` styles only the workspace (plus `icon-button`, `hidden-input` and `auth-notice`, which the shell uses too).
- `src/i18n.ts` — only the shell's own strings (`ShellStrings`, de/en). The workspace's strings come from glpython-editor's `coreStrings`, so don't copy them here. A new workspace string goes into glpython-editor's `src/i18n.ts`.
- `src/tabProjects.ts`: per-tab projects (P25). The tab's id is in sessionStorage and `history.state` (never in the address); projects are in localStorage, one entry per id. Nothing is deleted when a tab goes away: a page can't tell a close from iPad Safari unloading it (only `history.state` survives that). Open tabs answer over a BroadcastChannel, which finds duplicated tabs and the projects for «Zuletzt geschlossen».
-- `src/projectStorage.ts` (folder/ZIP) and `src/projectShare.ts` (`?project=` share links, lz-string, versioned payload: v1 every file's code, v2 also libraries by URL, fetched by `src/libraries.ts`; a link that can't be read opens an empty project with a notice).
+- `src/projectStorage.ts` (folder/ZIP) and `src/projectShare.ts` (`?project=` share links, lz-string, versioned payload: v1 every file's code, v2 also libraries by URL, fetched by `src/libraries.ts`; optional `openFile`, the tab to open with (a library by URL once fetched, unless the learner chose a tab: `tabChosenRef`), kept on the `TabEntry`, in «Teilen» links and in the ZIP; the tabs in the link's order (`fileOrder`), which «Teilen» keeps; a link that can't be read opens an empty project with a notice).
+- `src/markdown.ts`: the workspace's `renderMarkdown` (marked + DOMPurify, both pinned; HTML in the Markdown becomes text, links get `target="_blank"` and `rel="noopener noreferrer"`).
- `src/auth.ts` — MSAL. Only active with `VITE_ENTRA_CLIENT_ID` in `.env.local` (README «Microsoft sign-in»).
- `vite.config.ts` — `optimizeDeps.exclude: ['glpython-editor']` keeps the editor's worker next to its `dist/index.js`. Don't remove it.
diff --git a/README.md b/README.md
index 1179254..2caa42f 100644
--- a/README.md
+++ b/README.md
@@ -146,6 +146,43 @@ lock: it can be read, run and imported, but not edited, renamed or deleted -
e.g. a parser that learners use as a black box. This local format is also the shape planned for OneDrive
folder synchronization.
+**A task's instructions as a tab.** A share link can name the tab that is
+open when the project opens: `"openFile": "aufgabe.md"` next to `mainFile`
+(any version; one that isn't among the files is ignored, and an IDE from
+before opens the link as it did). ▶, **Tests** and **Visualisieren** always
+act on `mainFile`, whichever tab is open. A Markdown file (`.md`) has a switch
+**Ansicht / Text** at the end of the tabs: a read-only one opens as a page, an
+editable one as its text. The page is rendered with
+[marked](https://marked.js.org/) and sanitized with
+[DOMPurify](https://github.com/cure53/DOMPurify) (both pinned): HTML written
+in the Markdown shows as text, scripts, event attributes and `javascript:`
+links are removed, links open in a new tab, code is only shown. The tab's
+project, **Teilen**, a reload and the ZIP (`"openFile"` in `glpython.json`)
+keep `openFile`. The instructions can come by URL, like a library (a shorter
+link for the hand-in): that tab becomes the open one once it has loaded,
+unless the learner has chosen another tab in the meantime; if it can't be
+loaded, `mainFile` stays open. The tabs follow the order of the files in the
+link (libraries by URL among them), and **Teilen** writes them in that order;
+a new file comes last. For example:
+
+```json
+{
+ "v": 2,
+ "name": "Aufgabe 1",
+ "mainFile": "auswerter.py",
+ "openFile": "aufgabe.md",
+ "files": {
+ "aufgabe.md": { "path": "aufgabe.md", "url": "https://…/aufgabe.md", "readOnly": true },
+ "parser.py": { "path": "parser.py", "url": "https://…/parser.py", "readOnly": true },
+ "auswerter.py": { "path": "auswerter.py", "label": "auswerter", "kind": "python", "code": "…" }
+ }
+}
+```
+
+as `?project=` + `LZString.compressToEncodedURIComponent(JSON.stringify(…))`.
+A Markdown file can also carry its code (`"kind": "text", "code": "…"`,
+`"readOnly": true`); then it is open at once.
+
## Microsoft sign-in
Copy `.env.example` to `.env.local` and set the client ID from a Microsoft
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index 88a9f63..1321e06 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -370,6 +370,265 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
+### marked 18.1.1
+
+License: MIT · https://github.com/markedjs/marked
+
+```text
+# License information
+
+## Contribution License Agreement
+
+If you contribute code to this project, you are implicitly allowing your code
+to be distributed under the MIT license. You are also implicitly verifying that
+all code is your original work. ``
+
+## Marked
+
+Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
+Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+## Markdown
+
+Copyright © 2004, John Gruber
+http://daringfireball.net/
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
+```
+
+### DOMPurify 3.4.17
+
+License: (MPL-2.0 OR Apache-2.0); used under Apache-2.0 · https://github.com/cure53/DOMPurify
+
+```text
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+```
+
### jszip 3.10.2
License: (MIT OR GPL-3.0-or-later) · https://github.com/Stuk/jszip
diff --git a/package-lock.json b/package-lock.json
index ac7e8ed..2937eb4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,10 +10,12 @@
"license": "MIT",
"dependencies": {
"@azure/msal-browser": "^5.22.0",
- "glpython-editor": "git+https://github.com/glpython-edu/glpython-editor.git#v0.1.27",
+ "dompurify": "3.4.17",
+ "glpython-editor": "git+https://github.com/glpython-edu/glpython-editor.git#v0.1.29",
"jszip": "^3.10.2",
"lucide-react": "^1.47.0",
"lz-string": "^1.5.0",
+ "marked": "18.1.1",
"react": "^19.2.8",
"react-dom": "^19.2.8"
},
@@ -54,6 +56,7 @@
"resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.7.0.tgz",
"integrity": "sha512-gIwR1HrJrrx+vfyOhYmCZ0/JcWqG5kbfG7+d3f/C1LXk2EvzAbHSg3MQ5lO2sMlo9izoAZ04shohfKLVT6crVA==",
"license": "MIT",
+ "optional": true,
"peer": true,
"dependencies": {
"state-local": "^1.0.6"
@@ -64,6 +67,7 @@
"resolved": "https://registry.npmjs.org/@monaco-editor/react/-/react-4.7.0.tgz",
"integrity": "sha512-cyzXQCtO47ydzxpQtCGSQGOC8Gk3ZUeBXFAxD+CWXYFo5OqZyZUonFl0DwUlTyAfRHntBfw2p3w4s9R6oe1eCA==",
"license": "MIT",
+ "optional": true,
"peer": true,
"dependencies": {
"@monaco-editor/loader": "^1.5.0"
@@ -704,8 +708,7 @@
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
"license": "MIT",
- "optional": true,
- "peer": true
+ "optional": true
},
"node_modules/@vitejs/plugin-react": {
"version": "6.1.1",
@@ -761,11 +764,10 @@
}
},
"node_modules/dompurify": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.15.tgz",
- "integrity": "sha512-EUBjM+B+lkDE41iE82DDSCfkoPGfXx8IxFxPMjNzm/Uk4xDet77rTN9wqlxlVg71kK7XGuUMv6wUxJUwwv+Xyw==",
+ "version": "3.4.17",
+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.17.tgz",
+ "integrity": "sha512-B/pSlYVHQ58kqISD/yDjuJ1yfzI34m1gF4lAod2bwSRhiN4K5Cl3H8Af7hqB2PmTL911tdEudnnXn5FnhRoz0w==",
"license": "(MPL-2.0 OR Apache-2.0)",
- "peer": true,
"optionalDependencies": {
"@types/trusted-types": "^2.0.7"
}
@@ -805,13 +807,30 @@
},
"node_modules/glpython-editor": {
"version": "0.1.0",
- "resolved": "git+ssh://git@github.com/glpython-edu/glpython-editor.git#104e6c13900f6e0c32cc109d1e52ad0056441db9",
+ "resolved": "git+ssh://git@github.com/glpython-edu/glpython-editor.git#97ad352ae6e7c9ff436b8f8c9bd01e0a766f80bc",
"license": "MIT",
+ "bin": {
+ "glpython-tree": "bin/glpython-tree.mjs"
+ },
"peerDependencies": {
"@monaco-editor/react": "^4.7.0",
"lucide-react": "^1.47.0",
"react": "^19.2.8",
"react-dom": "^19.2.8"
+ },
+ "peerDependenciesMeta": {
+ "@monaco-editor/react": {
+ "optional": true
+ },
+ "lucide-react": {
+ "optional": true
+ },
+ "react": {
+ "optional": true
+ },
+ "react-dom": {
+ "optional": true
+ }
}
},
"node_modules/immediate": {
@@ -1139,16 +1158,15 @@
}
},
"node_modules/marked": {
- "version": "14.0.0",
- "resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz",
- "integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==",
+ "version": "18.1.1",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-18.1.1.tgz",
+ "integrity": "sha512-zEGgrtUG8crk+TrMacJSVABU4DYDDkS8uqgU3ohrn/2fW9C2AEfUrO3m6IhpIpQpl7YcVpiXXC9cSMWDANT3dg==",
"license": "MIT",
- "peer": true,
"bin": {
"marked": "bin/marked.js"
},
"engines": {
- "node": ">= 18"
+ "node": ">= 20"
}
},
"node_modules/monaco-editor": {
@@ -1156,12 +1174,38 @@
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.57.0.tgz",
"integrity": "sha512-5BkI9KGoqrNvBGUe15/QlZq3OooZ8WLg1AxTpaqHRCP3HNpzPPZKE2EDz8M7c+VRmCeUw1Brp4cx/PWm3kI/5A==",
"license": "MIT",
+ "optional": true,
"peer": true,
"dependencies": {
"dompurify": "3.4.15",
"marked": "14.0.0"
}
},
+ "node_modules/monaco-editor/node_modules/dompurify": {
+ "version": "3.4.15",
+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.15.tgz",
+ "integrity": "sha512-EUBjM+B+lkDE41iE82DDSCfkoPGfXx8IxFxPMjNzm/Uk4xDet77rTN9wqlxlVg71kK7XGuUMv6wUxJUwwv+Xyw==",
+ "license": "(MPL-2.0 OR Apache-2.0)",
+ "optional": true,
+ "peer": true,
+ "optionalDependencies": {
+ "@types/trusted-types": "^2.0.7"
+ }
+ },
+ "node_modules/monaco-editor/node_modules/marked": {
+ "version": "14.0.0",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz",
+ "integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==",
+ "license": "MIT",
+ "optional": true,
+ "peer": true,
+ "bin": {
+ "marked": "bin/marked.js"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
"node_modules/nanoid": {
"version": "3.3.19",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz",
@@ -1407,6 +1451,7 @@
"resolved": "https://registry.npmjs.org/state-local/-/state-local-1.0.7.tgz",
"integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==",
"license": "MIT",
+ "optional": true,
"peer": true
},
"node_modules/string_decoder": {
diff --git a/package.json b/package.json
index 1624a81..96bfeb8 100644
--- a/package.json
+++ b/package.json
@@ -13,10 +13,12 @@
},
"dependencies": {
"@azure/msal-browser": "^5.22.0",
- "glpython-editor": "git+https://github.com/glpython-edu/glpython-editor.git#v0.1.27",
+ "dompurify": "3.4.17",
+ "glpython-editor": "git+https://github.com/glpython-edu/glpython-editor.git#v0.1.29",
"jszip": "^3.10.2",
"lucide-react": "^1.47.0",
"lz-string": "^1.5.0",
+ "marked": "18.1.1",
"react": "^19.2.8",
"react-dom": "^19.2.8"
},
diff --git a/scripts/check-ide-browser.mjs b/scripts/check-ide-browser.mjs
index 681dbd7..9de131f 100644
--- a/scripts/check-ide-browser.mjs
+++ b/scripts/check-ide-browser.mjs
@@ -9,7 +9,11 @@
// a link cut at 2,083 characters, the note for a long link;
// - ▶ and «Tests» on a project of two files; ⋮ «Info» and its update check;
// - input() in the console's input line: ▶, a recursive REPL called in the
-// REPL, Stop → EOFError.
+// REPL, Stop → EOFError;
+// - a task's instructions as a tab (P45): a link's `openFile` and a
+// read-only aufgabe.md shown as a page («Ansicht / Text»), ▶, «Tests»
+// and «Visualisieren» on the file that runs, «Teilen» and a reload keep
+// it; an old link as before; the page's HTML sanitized.
// The browser's «leave the page» question and the iPad cases stay manual:
// headless Chrome can't confirm them.
//
@@ -31,11 +35,19 @@ const server = spawn('npx', ['vite', 'preview', '--port', String(port), '--stric
// The libraries a link names by URL: bib.py, with CORS as GitHub Pages sends
// it; anything else is a 404 (with CORS too, so the IDE sees the status).
const library = 'def gross(text):\n return text.upper()\n'
+// Also a task's instructions (aufgabe.md), and the same 3 seconds late.
+let aufgabe
const libraryServer = http.createServer((request, response) => {
const headers = { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'text/plain; charset=utf-8' }
- if (new URL(request.url, libraryBase).pathname === '/bib.py') {
+ const pathname = new URL(request.url, libraryBase).pathname
+ if (pathname === '/bib.py') {
response.writeHead(200, headers)
response.end(library)
+ } else if (pathname === '/aufgabe.md' || pathname === '/langsam/aufgabe.md') {
+ setTimeout(() => {
+ response.writeHead(200, headers)
+ response.end(aufgabe)
+ }, pathname === '/aufgabe.md' ? 0 : 3000)
} else {
response.writeHead(404, headers)
response.end('not found')
@@ -45,16 +57,29 @@ const stop = () => { server.kill(); libraryServer.close() }
process.on('exit', stop)
const file = (path, code, extra = {}) => ({ path, label: path, kind: 'python', code, ...extra })
-const link = (files, mainFile, version = 1) => {
+const link = (files, mainFile, version = 1, extra = {}) => {
const url = new URL(base)
- url.searchParams.set('project', lz.compressToEncodedURIComponent(JSON.stringify({ v: version, name: 'Check', mainFile, files: Object.fromEntries(files.map((entry) => [entry.path, entry])) })))
+ url.searchParams.set('project', lz.compressToEncodedURIComponent(JSON.stringify({ v: version, name: 'Check', mainFile, ...extra, files: Object.fromEntries(files.map((entry) => [entry.path, entry])) })))
return url.toString()
}
+const payloadOf = (shareUrl) => {
+ const url = new URL(shareUrl)
+ const encoded = url.searchParams.get('project') ?? new URLSearchParams(url.hash.slice(1)).get('project')
+ return JSON.parse(lz.decompressFromEncodedURIComponent(encoded))
+}
const helfer = 'def doppelt(x):\n return 2 * x\n'
const main = 'from helfer import doppelt\n\n\ndef viermal(x):\n """\n >>> viermal(2)\n 8\n """\n return doppelt(doppelt(x))\n\n\nprint(viermal(21))\n'
const twoFiles = link([file('helfer.py', helfer), file('main.py', main)], 'main.py')
const greeting = link([file('main.py', 'name = input("Name: ")\nprint("Hallo", name)\n')], 'main.py')
const language = link([file('main.py', 'def berechnen(text):\n return eval(text)\n\ndef repl():\n text = input("> ")\n if text == "ende":\n return\n print(berechnen(text))\n repl()\n')], 'main.py')
+// A task: the file to work in, a library by URL and the instructions, open
+// at the start.
+const auswerter = 'from bib import gross\n\n\ndef auswerten(text):\n """\n >>> auswerten("ok")\n \'OK\'\n """\n return gross(text)\n\n\nprint(auswerten("hallo"))\n'
+aufgabe = '# Aufgabe 1\n\nErgänzen Sie `auswerten` in **auswerter.py**.\n\n- Tab *aufgabe.md*: diese Anleitung\n- Tab *auswerter.py*: Ihr Code\n\n```python\nauswerten("ok")\n```\n\n| Datei | Zweck |\n|---|---|\n| bib.py | Bibliothek |\n\n[Python-Doku](https://docs.python.org/3/)\n'
+const task = (instructions = aufgabe) => link([file('auswerter.py', auswerter), { path: 'bib.py', url: `${libraryBase}bib.py`, readOnly: true }, { path: 'aufgabe.md', label: 'aufgabe', kind: 'text', code: instructions, readOnly: true }], 'auswerter.py', 2, { openFile: 'aufgabe.md' })
+// The same with aufgabe.md by URL, first in the link, as a course writes it.
+const taskByUrl = (url) => link([{ path: 'aufgabe.md', url, readOnly: true }, { path: 'bib.py', url: `${libraryBase}bib.py`, readOnly: true }, file('auswerter.py', auswerter)], 'auswerter.py', 2, { openFile: 'aufgabe.md' })
+const hostile = '# Test\n\n\n\n
\n\n[Klick](javascript:window.hacked=3)\n\na\n'
const withReadOnly = link([file('bib.py', library, { readOnly: true }), file('main.py', 'from bib import gross\nprint(gross("hallo"))\n')], 'main.py')
const byUrl = (url) => link([{ path: 'bib.py', url, readOnly: true }, file('main.py', 'from bib import gross\nprint(gross("hallo"))\n')], 'main.py', 2)
// A file that compresses badly, for a link longer than 2,083 characters.
@@ -291,6 +316,129 @@ try {
await context.close()
})
+ const markdownSwitch = (page) => page.locator('.markdown-switch button[aria-pressed="true"]').innerText()
+ await check('a task: opens on aufgabe.md as a page; ▶, Tests, Visualisieren run auswerter.py', async () => {
+ const context = await newContext()
+ const page = await open(context, task())
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'aufgabe.md')
+ assert.equal(await page.locator('.markdown-page h1').innerText(), 'Aufgabe 1')
+ assert.equal(await page.locator('.markdown-page table td').first().innerText(), 'bib.py')
+ assert.equal((await page.locator('.markdown-page pre code').innerText()).trim(), 'auswerten("ok")')
+ assert.deepEqual(await page.locator('.markdown-page a').evaluateAll((links) => links.map((a) => [a.target, a.rel])), [['_blank', 'noopener noreferrer']])
+ assert.equal(await markdownSwitch(page), 'Ansicht')
+ // As text: read-only, typing changes nothing.
+ await page.locator('.markdown-switch button', { hasText: 'Text' }).click()
+ await page.locator('.markdown-page').waitFor({ state: 'detached' })
+ await typeAtStart(page, 'xyz')
+ assert.equal(await editorText(page), aufgabe)
+ await page.locator('.markdown-switch button', { hasText: 'Ansicht' }).click()
+ await page.locator('.markdown-page').waitFor()
+ // The drawer: the lock, no rename or delete.
+ await page.getByRole('button', { name: 'Dateien' }).click()
+ const row = page.locator('.ide-file-list li', { hasText: 'aufgabe.md' })
+ assert.equal(await row.locator('.ide-file-read-only').count(), 1)
+ assert.equal(await row.getByRole('button', { name: /umbenennen|löschen/ }).count(), 0)
+ await page.keyboard.press('Escape')
+ // The buttons act on the file that runs, with aufgabe.md open.
+ await pythonReady(page)
+ await page.getByRole('button', { name: 'Ausführen' }).click()
+ await page.waitForFunction(() => document.querySelector('.console')?.textContent.includes('HALLO'), null, { timeout: 60000 })
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'aufgabe.md')
+ await page.getByRole('button', { name: 'Tests', exact: true }).click()
+ await page.locator('.test-summary').waitFor({ timeout: 60000 })
+ assert.equal(await page.locator('.test-summary').innerText(), '1 von 1 Beispielen bestanden')
+ await page.getByRole('button', { name: 'Visualisieren' }).click()
+ await page.waitForFunction(() => document.querySelector('.visualizer-view')?.textContent.includes('def auswerten(text):'), null, { timeout: 60000 })
+ await context.close()
+ })
+
+ await check('a task: «Teilen» and a reload keep openFile and readOnly', async () => {
+ const context = await newContext()
+ const page = await open(context, task())
+ await page.locator('.ide-library-name', { hasText: 'bib.py' }).count()
+ await page.waitForFunction(() => document.querySelector('.ide-notice') === null || !document.querySelector('.ide-notice').textContent.includes('bib.py'), null, { timeout: 15000 })
+ await page.getByRole('button', { name: 'Teilen' }).click()
+ await page.waitForTimeout(500)
+ const shared = payloadOf(await page.evaluate(() => navigator.clipboard.readText()))
+ assert.equal(shared.openFile, 'aufgabe.md')
+ assert.equal(shared.mainFile, 'auswerter.py')
+ assert.deepEqual([shared.files['aufgabe.md'].readOnly, shared.files['aufgabe.md'].code], [true, aufgabe])
+ assert.deepEqual(shared.files['bib.py'], { path: 'bib.py', url: `${libraryBase}bib.py`, readOnly: true })
+ await page.reload()
+ await page.waitForFunction(() => window.monaco?.editor.getEditors().length > 0, null, { timeout: 60000 })
+ await page.waitForTimeout(500)
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'aufgabe.md')
+ assert.equal(await page.locator('.markdown-page h1').innerText(), 'Aufgabe 1')
+ assert.equal((await stored(page)).files['aufgabe.md'].readOnly, true)
+ await context.close()
+ })
+
+ await check('a task by URL: aufgabe.md opens as a page once loaded, tabs in the link\'s order', async () => {
+ const context = await newContext()
+ const page = await open(context, taskByUrl(`${libraryBase}aufgabe.md`))
+ await page.locator('.markdown-page h1').waitFor({ timeout: 15000 })
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'aufgabe.md')
+ assert.equal(await markdownSwitch(page), 'Ansicht')
+ assert.deepEqual(await tabs(page), ['aufgabe.md', 'bib.py', 'auswerter.py'])
+ await page.getByRole('button', { name: 'Teilen' }).click()
+ await page.waitForTimeout(500)
+ const shared = payloadOf(await page.evaluate(() => navigator.clipboard.readText()))
+ assert.equal(shared.openFile, 'aufgabe.md')
+ assert.deepEqual(Object.keys(shared.files), ['aufgabe.md', 'bib.py', 'auswerter.py'])
+ assert.deepEqual(shared.files['aufgabe.md'], { path: 'aufgabe.md', url: `${libraryBase}aufgabe.md`, readOnly: true })
+ await page.reload()
+ await page.waitForFunction(() => window.monaco?.editor.getEditors().length > 0, null, { timeout: 60000 })
+ await page.locator('.markdown-page h1').waitFor({ timeout: 15000 })
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'aufgabe.md')
+ assert.deepEqual(await tabs(page), ['aufgabe.md', 'bib.py', 'auswerter.py'])
+ await context.close()
+ })
+
+ await check('a task by URL: a slow aufgabe.md doesn\'t take the tab the learner chose', async () => {
+ const context = await newContext()
+ const page = await open(context, taskByUrl(`${libraryBase}langsam/aufgabe.md`))
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'auswerter.py', 'the file that runs until it has loaded')
+ await openTab(page, 'bib.py')
+ await page.locator('.editor-tab', { hasText: 'aufgabe.md' }).waitFor({ timeout: 15000 })
+ await page.waitForTimeout(500)
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'bib.py')
+ await context.close()
+ })
+
+ await check('a task by URL: an aufgabe.md that fails leaves the file that runs open', async () => {
+ const context = await newContext()
+ const page = await open(context, taskByUrl(`${libraryBase}fehlt/aufgabe.md`))
+ await page.waitForFunction(() => document.querySelector('.ide-notice')?.textContent.includes('HTTP 404'), null, { timeout: 15000 })
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'auswerter.py')
+ assert.deepEqual(await tabs(page), ['bib.py', 'auswerter.py'])
+ await context.close()
+ })
+
+ await check('an old link: opens on the file that runs, Markdown as text', async () => {
+ const context = await newContext()
+ const page = await open(context, link([file('main.py', 'print(1)\n'), { path: 'notizen.md', label: 'notizen', kind: 'text', code: '# Notizen\n' }], 'main.py', 1, { openFile: 'fehlt.md' }))
+ assert.equal(await page.locator('.editor-tab.active').innerText(), 'main.py')
+ assert.equal(await page.locator('.markdown-switch').count(), 0)
+ await openTab(page, 'notizen.md')
+ assert.equal(await markdownSwitch(page), 'Text', 'an editable file opens as its text')
+ assert.equal(await page.locator('.markdown-page').count(), 0)
+ await context.close()
+ })
+
+ await check('a task: the page shows HTML as text, runs no script, no javascript: link', async () => {
+ const context = await newContext()
+ const page = await open(context, task(hostile))
+ const pageText = await page.locator('.markdown-page').innerText()
+ assert.match(pageText, /