Skip to content

Commit 0a8a8b0

Browse files
committed
Add a README for the MD renderer explaining quirks
1 parent 9aa897b commit 0a8a8b0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

mfr/extensions/md/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Using Markdown-it with plugins
2+
3+
If we had `npm`, here were the would-be configuration.
4+
5+
```bash
6+
7+
npm install @centerforopenscience/[email protected]
8+
npm install [email protected]
9+
npm install [email protected]
10+
npm install [email protected]
11+
npm install [email protected]
12+
```
13+
14+
For MFR, a customized local copy of each script is stored in the extension's static folder. There are a few issues:
15+
16+
* MFR scripts run directly in the browser without Babel. For ES5 compatibility, developers must use [Babel](https://babeljs.io/repl/) to convert ES6 `markdown-it-highlightjs` to an ES5 version.
17+
18+
* MFR does not use a package manager. Thus, `require` is **NOT** available. For the `viewer.mako` to be able to load these libraries, customization is necessary to export via `root.<PLUGIN_NAME>`. The main script in the `viewer.mako` uses `window.<PLUGIN_NAME>` to access them. `markdown-it` and `markdown-it-sanitizer` are already set up to be exported code. MFR loads the `min` version directly. `markdown-it-toc`, `markdown-it-highlightjs`, `markdown-it-ins-del` and `markdown-it-mathjax` are not. The following wrapper must be used.
19+
20+
```javascript
21+
(function (root, factory) {
22+
if (typeof exports === "object") {
23+
module.exports = factory();
24+
} else {
25+
root.<PLUGIN_NAME> = factory();
26+
}
27+
}) (this, function () {
28+
return function(md/*, optional arguments*/) {
29+
/* library code */
30+
}
31+
});
32+
```
33+
34+
Here is a list of the original copies of the scripts:
35+
36+
* [markdown-it@08.4.0](https://github.com/markdown-it/markdown-it/blob/8.4.0/bin/markdown-it.js)
37+
* [markdown-it-sanitizer@0.4.3](https://github.com/svbergerem/markdown-it-sanitizer/blob/v0.4.3/dist/markdown-it-sanitizer.min.js)
38+
* [markdown-it-mathjax@2.0.0](https://github.com/classeur/markdown-it-mathjax/blob/v2.0.0/markdown-it-mathjax.js)
39+
* [markdown-it-toc@1.1.1](https://github.com/cos-forks/markdown-it-toc/blob/1.1.1/index.js)
40+
* [markdown-it-ins-del@1.0.0](https://github.com/brianjgeiger/markdown-it-ins-del/blob/1.0.0/index.js)
41+
* [markdown-it-higlightjs@3.0.0](https://github.com/cslzchen/markdown-it-highlightjs/blob/release/3.0.0/index.es5.js)

0 commit comments

Comments
 (0)