GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Blocks Embedding

This view

  • Original page
  • New address

GeezerVison is showing makecode.com — Blocks embedding

Skip to main content
About MakeCode Blog Online Learning Contact Us Tools
Technical Docs
JS Editor Features Programming Language Async Functions Partial Flashing Source Embedding Updating Blockly Version Accessibility Profiling Debugging Hardware
Creating Targets
pxtarget.json Defining Blocks Auto-generation of .d.ts Static File Drops Simulator Theming Editor Embedding resources
Creating Extensions
Getting started pxt.json Extension versioning Extension localization Extension approval Editor extensions GitHub Extension Authoring
Writing Docs
Macros Anchors Tutorials User Tutorials Skillmaps Routing Licensing Testing
Translations
Translation languages Localization files Parts to translate Translating markdown Translator roles In context translation
Blocks Embedding
Command Line Interface
install build bump deploy console gdb staticpkg update pyconv hidserial hiddmesg login
Labs UF2 File Format Accessibility Telemetry

Blocks embedding

MakeCode provides a lightweight blocks rendering engine that renders code snippets as SVG images.

The Curse of screenshots

Unlike text based programming languages, block-based snippets aren't easily rendered in a documentation page. A quick solution is take screenshots of the snippets but things can quickly become unsustainable:

  • screenshots can't be compiled - so it's hard to maintain them
  • screenshots are not localizable - non-English speaking users won't be able to read the blocks
  • screenshots aren't easily reloaded into the editor
  • screenshots don't play well with source control systems - you cannot diff changes efficiently

Rendering blocks on the spot

The MakeCode approach in solving this problem is to render the JavaScript code snippets on a client using the same block rendering engine as the editor. Under the hood, an IFrame from the MakeCode editor will render the blocks for you.

GitHub pages

You can use GitHub pages to render your README.md file as a web site.

  • enable GitHub pages on your repository
  • add the url of the editor in _config.yml (including trailing /)
  makecode:
    home_url: https://makecode.com/
  • copy the following text at the bottom of your README.md file
<script src="https://makecode.com/gh-pages-embed.js"></script><script>makeCodeRender("{{ site.makecode.home_url }}", "{{ site.github.owner_name }}/{{ site.github.repository_name }}");</script>

Other Plugins

Here are some sample integrations for various documentation/blogging engines.

  • React component
  • HTML only
  • MkDocs plugin

Manual Implementation

You can find example of custom blocks embedding in the documentation of your favorite editor.

Edit this page on GitHub
Edit template of this page on GitHub

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.