A Node.js tool and template repository for generating syntax-highlighted HTML code snippets for use in RISE modules.
This repository is a template. Please ignore if you have already completed this setup. To use it for your own course:
- Click "Use this template" on the GitHub page to create your own repository from this template.
- Clone your new repository to your local machine.
- Create a
.envfile in the root of your project with the following contents:Replace these values with the organization and repository name of the template you create.GH_ORG= GH_REPOSITORY= - Follow the instructions below to add your code snippets and build your site.
- Place formatted code files in
src/snippets/(group by language). - On build each file is converted to a standalone, syntax-highlighted (based on language) HTML snippet using Handlebars and Highlight.js.
- On build output is written to the
public/directory, including anindex.htmland aniframes.htmlwith ready-to-copy iframe tags.
Do not delete existing snippets unless 100% sure as they are used in live modules.
- Create a branch for your snippets.
- Add your code snippets to
src/snippets/(create a subfolder for your language if not already present).
- To view locally run
npm buildto generatepublic.
- Open a Pull Request to
main.
On merge, a GitHub Action will:
- Build the HTML output.
- Deploy the
public/directory to thegh-pagesbranch.
Your snippets will then be available online for embedding in RISE modules.
src/
module-projects # Store Specific Projects Related to Modules
snippets/ # Add your code files here
templates/ # Handlebars templates
utils/ # Build utilities
index.js # Main script for processing snippets
public/ # Generated HTML output (auto-deployed)
npm install
npm run buildThis project uses Vitest (https://vitest.dev/) for testing. To run tests:
npm test