# Hue MD for GitHub GitHub does not render Hue Markdown. This folder gives you three ways to work around that: | Tool | Does | | :--- | :--- | | [GitHub Action](#github-action) | Writes a GitHub Markdown `.md` copy of each `.hue.md` file in CI | | [Pre-commit hook](#pre-commit-hook) | Writes the same copy on your machine when you commit | | [Browser extension and userscript](#browser-extension-and-userscript) | Renders Hue on github.com pages | In the `.md` copy, boxes become GitHub alerts (`> [!NOTE]`, `> [!WARNING]` and so on). ## GitHub Action Add `.github/workflows/hue-sync.yml`: ```yaml name: Hue Markdown Sync on: push: paths: ['**/*.hue.md'] pull_request: paths: ['**/*.hue.md'] permissions: contents: write jobs: sync: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: spingras/hue-md/packages/github-hue/action@v0.2.8 with: check-only: ${{ github.event_name == 'pull_request' }} commit: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} ``` | Input | Default | Does | | :--- | :--- | :--- | | `pattern` | `**/*.hue.md` | Files to convert | | `mode` | `auto` | How spans convert: `auto`, `bold`, `latex` or `plain` | | `check-only` | `false` | Fails when a `.md` copy is out of date, and writes nothing | | `commit` | `false` | Commits and pushes the updated `.md` files. The run fails when the commit or push fails | | `commit-message` | `chore: sync Hue Markdown to GitHub-flavored Markdown [skip ci]` | Message for that commit | The Action only overwrites a `.md` file that it generated itself. A hand-written `README.md` next to `README.hue.md` stays as it is. ## Pre-commit hook Copy [`hooks/pre-commit`](hooks/pre-commit) to `.git/hooks/pre-commit` in your repository. On macOS and Linux, make it executable with `chmod +x .git/hooks/pre-commit`. The hook needs Node.js. It uses an installed `hue-md`, or else `npx hue-md`. If you have a clone of this repository, you can instead run `hooks/install-hooks.sh` (or `hooks/install-hooks.ps1` on Windows) from inside your repository. It uses the hooks folder that git uses, also when `core.hooksPath` is set. It does not replace a `pre-commit` hook that is not the Hue hook. When you commit a `.hue.md` file, the hook writes and stages its `.md` copy from the staged content, so unstaged edits stay out of the commit. Like the Action, it only overwrites a `.md` file that it generated. When a conversion fails, the hook stops the commit; `git commit --no-verify` skips it. ## Browser extension and userscript Both render Hue in the Markdown views on github.com: files, READMEs, issues, pull requests and comments. `- [ ]` and `- [x]` stay GitHub's own checkboxes. Colors follow GitHub's light or dark theme. - **Userscript:** install Tampermonkey or Violentmonkey, then open [`hue-md.user.js`](https://github.com/spingras/hue-md/releases/latest/download/hue-md.user.js). - **Chrome or Edge:** extract [`hue-md-browser.zip`](https://github.com/spingras/hue-md/releases/latest/download/hue-md-browser.zip). Open `chrome://extensions` or `edge://extensions`, turn on **Developer mode**, select **Load unpacked** and pick the extracted folder. ## Development `extension/` and `userscript/` are generated from `src/content.js`. Edit `src/`, then rebuild from the repo root: ```bash node packages/github-hue/scripts/build.mjs ``` `npm test` at the repo root loads the built extension and userscript in a jsdom page that holds `demo/demo.hue.md` as GitHub renders it. Manual check: 1. Load the extension or install the userscript. 2. Open `demo/demo.hue.md` of this repository on github.com. 3. Check the colored spans, five colored boxes, two side-by-side boxes, the ◐ ! ? tasks next to two normal checkboxes, `Ctrl+Shift+V` and `Esc` as key caps, a blue 80% and a green 100% bar, and green added and red struck-through text. 4. Switch the GitHub theme (**Settings → Appearance**). The Hue colors follow.