Gistful for GitHub

Description

Gistful for GitHub embeds GitHub Gists in your posts and pages. It is a replacement for GistPress: existing [gist] shortcodes and pasted gist URLs keep working, so you can switch without editing your content.

Features:

  • Block editor block, [gistful] shortcode and pasted gist URLs (oEmbed-style) all supported. [gist] works too, as a compatibility alias for GistPress content (see the FAQ).
  • Local CSS, no browser requests to GitHub from the plugin’s own CSS and scripts. Gists are fetched and cached by your server. The only exception is images inside Markdown gists, which are served by GitHub.
  • Dark mode: follows the visitor’s system preference automatically, or force light or dark in the settings.
  • “Copy” button on every code and CSV file and “Copy all” on multi-file gists: copies exactly the lines shown, without line numbers (CSV files copy as CSV). Markdown files are shown rendered, so they have no Copy button. Can be turned off in the settings, per block, or with copy="no" on the shortcode.
  • Line numbers, line ranges and line highlighting, file selection for multi-file gists, and Markdown and CSV files rendered inline. Files GitHub shows with special viewers (notebooks, maps, 3D models) get a link to GitHub.
  • Migration tool (Tools > Gistful Migration) to convert GistPress content, with a backup so changes can be reverted.
  • Security hardening: gist HTML is sanitized with a strict allow-list, requests go only to GitHub over verified TLS with short timeouts and size limits, and the optional API token is read from a constant and never stored in the database or printed.
  • WP-CLI cache command and clean uninstall.

Credits: based on GistPress by Brady Vercher and Gary Jones (https://github.com/bradyvercher/gistpress).

External services

This plugin connects to GitHub, a code hosting service provided by GitHub, Inc., to fetch the gists you embed. Without it the plugin cannot display gists.

  • What is sent and when: when a post containing a gist is saved, and when a visitor views a post whose cached copy of the gist has expired, your server requests the gist from gist.github.com (the gist’s embed data) and, when that fails or to read the gist’s file names, from api.github.com. The request contains the gist ID, the selected file name if any, and a User-Agent with the plugin version and your site URL. If you define GISTFUL_GITHUB_TOKEN, that token is sent to api.github.com to authenticate. No data about your visitors is sent.
  • Images inside Markdown gists are loaded by the visitor’s browser directly from GitHub’s servers (for example githubusercontent.com), so GitHub receives the visitor’s IP address and browser details for those images.
  • GitHub Terms of Service: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service
  • GitHub Privacy Statement: https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement

Privacy

Your server contacts gist.github.com and api.github.com to fetch the gists you embed; no personal data of your visitors is sent, and the request carries a User-Agent with the plugin version and your site URL. The results are cached in your database. The plugin’s own CSS and scripts are served from your site and make no browser requests to external domains. Markdown gists may contain images, and those images are served by GitHub, so a visitor’s browser will request them from GitHub’s servers. The plugin does not set cookies or track visitors.

Source code

The full, unminified source, including the block source under src/, is available at https://github.com/gioxx/wp-gistful. The compiled block in build/ is produced with npm ci && npm run build (@wordpress/scripts).

Credits

Based on GistPress by Brady Vercher and Gary Jones: https://github.com/bradyvercher/gistpress

Blocks

This plugin provides 1 block.

  • GitHub Gist Embed a GitHub Gist.

Installation

  1. Upload the gistful folder to /wp-content/plugins/, or install the plugin from the Plugins screen.
  2. Activate it through the Plugins screen.
  3. Add the Gist block, use [gistful id="GIST_ID"], or paste a gist URL on its own line.
  4. Optional: adjust Settings > Gistful.

FAQ

How do I migrate from GistPress?

Deactivate GistPress, activate Gistful, then open Tools > Gistful Migration. Existing [gist] shortcodes and pasted URLs already render without changes; the tool converts GistPress content to the block if you want it, and keeps a backup.

What is the difference between [gistful] and [gist]?

[gistful] is the plugin’s own shortcode and always works. [gist] is the shortcode GistPress used: Gistful handles it only when no other plugin or theme registers it, so it never replaces another plugin’s handler by itself. If another plugin (for example Jetpack’s Shortcodes module) also handles [gist], a notice tells you; you can keep that plugin in charge, use the block or [gistful], or turn on the takeover option in Settings > Gistful.

How does dark mode work?

By default the color scheme follows the visitor’s system preference. In Settings > Gistful you can force light or dark. Themes can override the CSS custom properties on .gistful.

How do I disable the plugin’s CSS?

Untick the option to load the stylesheet in Settings > Gistful, then style the .gistful markup from your theme.

Does the plugin load any JavaScript on the frontend?

Only for the copy buttons: a small script served from your site (no external requests), loaded in the footer and only on pages that show a gist with the copy button enabled. Without JavaScript the gists display normally, just without the buttons. Turn the buttons off in Settings > Gistful, per block, or with copy="no" on the shortcode, and no script is loaded at all.

Can I use a GitHub token to raise API rate limits?

Yes. Define the constant in wp-config.php:

define( 'GISTFUL_GITHUB_TOKEN', 'your-token' );

The token is only read from this constant. It is never saved in the database and never printed. A token with no scopes is enough for public gists.

Why do some files show a link instead?

There are three cases:

  • Files GitHub displays with a special viewer (Jupyter notebooks, GeoJSON, TopoJSON and STL files) cannot be rendered inline, so a “View this file on GitHub” link is shown.
  • Gists or files that are too large or that GitHub returns truncated are replaced by a link to the gist. The size limit is fixed (2 MB per response) and is not a setting.
  • If GitHub cannot be reached and there is no saved backup copy of the gist for that post, a plain link to the gist is shown until the next successful fetch.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Gistful for GitHub” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Gistful for GitHub” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

0.3.1

  • First release on the WordPress.org Plugin Directory. No functional changes from 0.3.0.
  • Updated build tooling dependencies.

0.3.0

  • New: [gistful] shortcode. [gist] remains as a GistPress compatibility alias, but no longer replaces another plugin’s [gist] handler unless the new takeover option in Settings > Gistful is on.
  • The conflict notice shows only on the Plugins and Gistful settings screens.
  • readme: documented the connection to GitHub (External services).

0.2.1

  • Text domain changed to gistful-for-github to match the WordPress.org slug.

0.2.0

  • New: “Copy” button on every code and CSV file and “Copy all” on multi-file gists (opt out in the settings, per block or with copy="no").
  • Fix: a gist that GitHub occasionally serves without syntax highlighting is cached for at most an hour and never replaces a highlighted backup of the same code.
  • Plugins screen: “View on GitHub” and “More plugins by Gioxx” links.

0.1.0

  • Initial release: block, shortcode and URL embeds, local CSS, dark mode, GistPress migration tool, security hardening, WP-CLI cache command.