{"id":20660983,"url":"https://github.com/liatemplates/skulpt","last_synced_at":"2026-05-08T06:02:30.638Z","repository":{"id":107256848,"uuid":"156858108","full_name":"LiaTemplates/Skulpt","owner":"LiaTemplates","description":"LiaScript template for start creating Python-Tutorials with Skulpt","archived":false,"fork":false,"pushed_at":"2020-12-02T19:36:07.000Z","size":175,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T12:16:31.347Z","etag":null,"topics":["liascript","python","python-tutorial","template","tutorial"],"latest_commit_sha":null,"homepage":"https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/skulpt/master/README.md","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiaTemplates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-09T12:18:01.000Z","updated_at":"2020-12-02T19:36:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"992f5551-2876-4505-bf95-0c4a004923ed","html_url":"https://github.com/LiaTemplates/Skulpt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FSkulpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FSkulpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FSkulpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FSkulpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiaTemplates","download_url":"https://codeload.github.com/LiaTemplates/Skulpt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242787961,"owners_count":20185193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["liascript","python","python-tutorial","template","tutorial"],"created_at":"2024-11-16T19:06:43.422Z","updated_at":"2025-12-16T05:22:02.011Z","avatar_url":"https://github.com/LiaTemplates.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nauthor:   André Dietrich\n\nemail:    andre.dietrich@ovgu.de\n\nversion:  0.0.4\n\nlanguage: en\n\nnarrator: US English Female\n\nlogo:     https://upload.wikimedia.org/wikipedia/commons/4/4a/Python3-powered_hello-world.svg\n\ncomment:  Macros for Python programming in LiaScript, by making use of the\n          skulpt interpreter.\n\nscript:   https://gitcdn.xyz/repo/liaTemplates/skulpt/master/js/skulpt.min.js\n          https://gitcdn.xyz/repo/liaTemplates/skulpt/master/js/skulpt-stdlib.js\n\n\n@Skulpt.eval\n\u003cscript\u003e\nfunction builtinRead(x) {\n  if (Sk.builtinFiles === undefined || Sk.builtinFiles[\"files\"][x] === undefined)\n    throw \"File not found: '\" + x + \"'\";\n  return Sk.builtinFiles[\"files\"][x];\n}\n\nfunction input(handle) {\n  return function(prompt) {\n    return new Promise((resolve, reject) =\u003e {\tsend.handle(\"input\", (e) =\u003e resolve(e)) });\n  }\n}\n\nSk.configure({\n  output: (e) =\u003e send.lia(e.toString()),\n  read: builtinRead,\n  inputfun: input(send.handle)});\n\nif( document.getElementById(\"@0\") ) {\n  Sk.canvas = \"@0\";\n  (Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = '@0';\n}\n\nsetTimeout( function(e) {\n  let myPromise = Sk.misceval.asyncToPromise(function() {\n    return Sk.importMainWithBody(\"\u003cstdin\u003e\", false, `@input`, true);\n  });\n  myPromise.then(function(mod){ send.lia(\"LIA: stop\") },\n   function(err) {\n       console.error(err);\n       send.lia(\"LIA: stop\");\n   });\n}, 150);\n\n\"LIA: terminal\";\n\u003c/script\u003e\n@end\n--\u003e\n\n# Skulpt - Template\n\nThis is a template for developing interactive Python courses with\n[LiaScript](https://LiaScript.github.io) and [Skulpt](http://www.skulpt.org).\n\n__Try it on LiaScript:__\n\nhttps://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/skulpt/master/README.md\n\n__See the project on Github:__\n\nhttps://github.com/liaTemplates/skulpt\n\n\n                         --{{1}}--\nThere are three ways to use this template. The easiest way is to use the\n`import` statement and the url of the raw text-file of the master branch or any\nother branch or version. But you can also copy the required functionionality\ndirectly into the header of your Markdown document, see therefor the\n[last slide](#5). And of course, you could also clone this project and change\nit, as you wish.\n\n                           {{1}}\n1. Load the macros via\n\n   `import: https://raw.githubusercontent.com/liaTemplates/skulpt/master/README.md`\n\n2. Copy the definitions into your Project\n\n3. Clone this repository on GitHub\n\n\n## `@Skulpt.eval`\n\n                         --{{0}}--\nAdd the macro `@Skulpt.eval` to the end of every Python code-block that you want\nto make executable and editable in LiaScript. The given code gets evaluate by\nthe Skulpt interpreter and the result is shown in a console below.\n\n\n``` python\nprint \"how many hellos should I print\"\n\nhellos = input()\n\nfor i in range(int(hellos)):\n  print \"Hello World #\", i\n```\n@Skulpt.eval\n\n\n## `@Skulpt.eval` with HTML\n\n                         --{{0}}--\nAdding an additional html-tag with an id-attribute you can also manipulate the\nDOM. If you add the class `persistent` to your tag, LiaScript will take care of\nyour changes and restore them, if you load reload the section.\n\n``` python\nimport document\n\npre = document.getElementById('edoutput')\npre.innerHTML = '''\n\u003ch1\u003e Skulpt can also access DOM! \u003c/h1\u003e\n'''\n```\n@Skulpt.eval\n\n\u003cspan id=\"edoutput\" class=\"persistent\"\u003e\n  This is a span with id (edoutput) and class(persistent).\n\u003c/span\u003e\n\n\n## `@Skulpt.eval` with Turtle\n\n                          --{{0}}--\nYou can use the Turtle implementation by adding another html-tag and by passing\nits id as a parameter to `@Skulpt.eval`. This element is then used as a canvas\nfor the turtle and if you also add class persistent to it, then you can preserve\nits state.\n\n```python\nimport turtle\n\nt = turtle.Turtle()\n\nfor c in ['red', 'green', 'yellow', 'blue']:\n    t.color(c)\n    t.forward(75)\n    t.left(90)\n    print \"color\", c\n```\n@Skulpt.eval(skulpt_canvas)\n\n\u003cdiv class=\"persistent\" id=\"skulpt_canvas\" style=\"border-style: solid; height: 400px; width: 400px\"\u003e\n  This is a div with id (skulpt_canvas) and class (persistent).\n\u003c/div\u003e\n\n## Implementation\n\n                         --{{0}}--\nThe code shows how the macro `@Skulpt.eval` is implemented. The script command\nat the top loads two javascript libraries that have to be called in order load\nthe interpreter.\n\n``` html\nscript: https://gitcdn.xyz/repo/liaTemplates/skulpt/master/js/skulpt.min.js\n        https://gitcdn.xyz/repo/liaTemplates/skulpt/master/js/skulpt-stdlib.js\n\n@Skulpt.eval\n\u003cscript\u003e\nfunction builtinRead(x) {\n  if (Sk.builtinFiles === undefined || Sk.builtinFiles[\"files\"][x] === undefined)\n    throw \"File not found: '\" + x + \"'\";\n  return Sk.builtinFiles[\"files\"][x];\n}\n\nfunction input(handle) {\n  return function(prompt) {\n    return new Promise((resolve, reject) =\u003e {\tsend.handle(\"input\", (e) =\u003e resolve(e)) });\n  }\n}\n\nSk.configure({\n  output: (e) =\u003e send.log(true, \"\", e.toString()),\n  read: builtinRead,\n  inputfun: input(send.handle)});\n\nif( document.getElementById(\"@0\") ) {\n  Sk.canvas = \"@0\";\n  (Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = '@0';\n}\n\nsetTimeout( function(e) {\n  let myPromise = Sk.misceval.asyncToPromise(function() {\n    return Sk.importMainWithBody(\"\u003cstdin\u003e\", false, `@input`, true);\n  });\n  myPromise.then(function(mod){ send.lia(\"LIA: stop\") },\n   function(err) {\n       console.error(err);\n       send.lia(\"LIA: stop\");\n   });\n}, 150);\n\n\"LIA: terminal\";\n\u003c/script\u003e\n@end\n```\n\n\n                         --{{1}}--\nIf you want to minimize loading effort in your LiaScript project, you can also\ncopy this code and paste it into your main comment header, see the code in the\nraw file of this document.\n\n                           {{1}}\nhttps://raw.githubusercontent.com/liaTemplates/skulpt/master/README.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Fskulpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliatemplates%2Fskulpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Fskulpt/lists"}