See Markdown JavaScript demos directly on github.com
mdjs-viewer Extension
[mdjs (Markdown JavaScript)](https://www.npmjs.com/package/@mdjs/core) allows to execute code and show interactive demos within your markdown documentation.
This extension takes this functionality and enables it directly on github.com.
You can see live demos in
- Github Markdown files (like README.md)
- Github Issues (incl. edit preview, new comment preview, new issue preview)
- ... more is planned but not yet implemented
## Security
Executing user code especially in github issues can be dangerous.
This extension isolates code executing as much as possible.
It can be considered as secure as any page that executes user code like codepen or jsfiddle.
The Security Measures are:
- not executing any code without user action (e.g. requires a click of a button first)
- shows demos/executes code within an iframe
- that uses [sandbox](https://www.w3schools.com/tags/att_iframe_sandbox.asp) with the following settings `sandbox=\"allow-scripts\"`
- populates the iframe with a data uri
- does not allow any requests (except unpkg) to got outside of the iframe
This prevents [all known attack vectors](https://github.com/open-wc/mdjs-viewer/issues/2). If you come up with new once please [report them](https://github.com/open-wc/mdjs-viewer/issues/new).
### Warning
In order to function this extension modifies the CSP (Content Security Policy) for github.com with the following rules:
- adds to script-src
- `'unsafe-inline'` to execute code blocks within the mdjs iframe
- `unpkg.com` to load user dependencies from within the mdjs iframe
## Demos
Enable the extension and visit the following pages
1. [Readme of demo-wc-card](https://github.com/daKmoR/demo-wc-card)
2. [Issues of demo-wc-card](https://github.com/daKmoR/demo-wc-card/issues/1)
## How does it work?
It adds a button `show demo ▹` to markdown pages and issues. Once you press it will get the raw md text which then gets pass though [mdjs](https://www.npmjs.com/package/@mdjs/core) and an extra plugin which replaces all imports (relative and bare imports) with [unpkg.com](https://unpkg.com/) urls with the `?module` flag. This way all dependencies can be directly loaded in the browser without the need of any service.
Finally we create an iframe with the content of the mdjs html and js output.
## Limits
In order to get the raw md content of an issues (only the first message not following comments) a request to api.github.com is required.
This request is only needed if you actually click on the `show demo ▹` button.
There is a hard limit of 60 anonymous api calls to github per hour.
For more an API key is needed. (You can not yet provide it to the extension 🙈 - feel free to open a feature request)
Source Manifest.json
How to download and manually install mdjs-viewer extension for Chrome
Looking for a way to install mdjs-viewer extensions for Chrome, you can search for them in the Chrome Web Store, clicking the "Add to Chrome" button, and following the straightforward process.
However, you may need to install mdjs-viewer extensions manually, this article outlines two simple methods to effortlessly install mdjs-viewer extensions, whether they come as unpacked folders in compressed formats like .zip or as .crx files.
Method 1: Download mdjs-viewer extension and manually install through Drag &Drop
If you ever need to manually install a mdjs-viewer extension for Chrome, don't worry, it's a simple process. Just follow these easy steps, and you will have your extension ready to use in no time.
Step 1: Download the mdjs-viewer Extension by clicking the "Download CRX" button on the website.
Look for the mdjs-viewer extension you wish to install. Go to the website and download the mdjs-viewer extension package, which is usually a .CRX file and comes in a zipped file. Here ".crx" file is the format for mdjs-viewer extension that contains all the data.
Step 2: Extract &Arrange Files
Once the file is downloaded, extract that file into its own folder. Similarly, give that extension files a permanent home. In other words, keep it in a folder that you don't accidentally delete it because these files will be needed to make that extension work.
Step 3: Go to the Chrome Extensions Page
Open Google Chrome and in the address bar, type chrome://extensions; it will open the Google Chrome extensions page. Make sure that "My extensions" is selected in the sidebar.
Step 4: Drag and Drop the Extension
Now, go to the folder where you extracted the mdjs-viewer extension and drag &drop the extension file from there anywhere onto the extension page within Google Chrome.
Step 5: Complete the Installation
Once you drag and drop the extension file, follow the steps that Google Chrome takes you through. Similarly, if the extension file is of .crx file format, you will be required to review the permissions and then add the extension.
Now, you can manage that added extension as you would like to with any other Chrome extension that you added through Chrome Webstore. Its icon will also appear in the Google Chrome Menu on the right side of the address bar once you activate it.
Method 2: Download mdjs-viewer extension for Chrome and install in Developer Mode
This is another method to install mdjs-viewer extension manually, but the twist is that here, you install by enabling the developer mode option provided in Google Chrome. This mode is commonly used for testing extensions or running unpublished tools.
Step 1: Download the mdjs-viewer extension file
Select and download the mdjs-viewer extension by clicking the 'Download CRX' button on the website.
Step 2: Extract the downloaded contents
Convert the file to a ZIP file if it is in CRX format then extract the mdjs-viewer extension zip file or folder that you downloaded. Make sure you extract it using the same folder name and keep it safely in another folder, so you don't delete it by mistake. The extracted folder will be needed to keep your mdjs-viewer extension running.
Step 3: Open Chrome Extension Setting Page
In the address bar of Google Chrome, type chrome://extensions and open the Chrome Extension Page.
Step 4: Enable Developer Mode
After opening the Chrome Extension page, look at the top right side, and you will find the toggle option of "Developer mode."Simply enable that developer mode option.
Step 5: Load the Unpacked Extension
Once you enable the developer mode option, you will see the menu of Load Unpacked, Pack Extensions and Update. From that, select the option "Load unpacked."
Step 6: Select the Extension Folder
Once the pop-up opens upon clicking Load unpacked, select the mdjs-viewer extension directory and click on the "Select Folder "button.
Step 7: Confirm and Install
After you select an extension folder of a Google Chrome extension you're installing manually, confirm its installation for the final time and let the installation complete.
Conclusion
Here we've made a step-by-step guide on How to manually install mdjs-viewer extension in 2 ways. We hope this guide proves helpful.
Similar Extensions
Open Github/Bitbucket in editor 58 0 ★ 50.72KiB
Gist Previewer 58 1 ★ 11.01KiB

OctoEdit 58 0 ★ 1.16MiB
GistRun 58 3 ★ 12.06KiB
github-readme-toc 58 2 ★ 2.22MiB
Open in StackBlitz 58 0 ★ 21.46KiB
GitHub submodule links 58 2 ★ 17.49KiB
Custom Elements Locator 58 3 ★ 3.46MiB
NPM + Repl.it 58 3 ★ 7.04KiB
github-find 58 1 ★ 40.7KiB
Hypothesify 58 0 ★ 18.26KiB
Codeflower 58 2 ★ 246KiB
Github Gist logo fixer 58 1 ★ 4.12KiB
SmartyList 58 3 ★ 356KiB
JS Tabby 58 7 ★ 246KiB
URLBuilder 58 0 ★ 157KiB
Codext 58 4 ★ 2.48MiB
OctoPermalinker 58 1 ★ 373KiB
BackMark - Back up the pages you bookmark 58 0 ★ 223KiB
gSites Embed Web App 58 4 ★ 42.36KiB
Where is it? 58 3 ★ 653KiB
Git flow (for Github) 58 1 ★ 218KiB
Git Mining 58 4 ★ 211KiB
Github Annotator 58 2 ★ 81.68KiB