-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
.gitignore
, README.md
, comments,
docstrs and style. [skip ci]
- Loading branch information
Showing
7 changed files
with
105 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
## Using Markdown-it with plugins | ||
|
||
## Markdown plus Mathjax readme | ||
|
||
Most of the packages are in there to try to match what the OSF wiki is doing. The two exceptions being markdown-it-highlightjs.js and markdown-it-mathjax.js. The highlighter matches the functionality of what is on the osf however, and the markdown-it-mathjax.js increases functionality with mathjax. | ||
|
||
to get all the libraries needed: | ||
Note: You do not need to use npm, you can easily get them off of github. | ||
If we had `npm`, here were the would-be configuration. | ||
|
||
```bash | ||
npm [email protected] | ||
|
@@ -15,38 +11,32 @@ npm install [email protected] | |
npm install [email protected] | ||
``` | ||
|
||
github: | ||
|
||
https://github.com/cos-forks/markdown-it-toc | ||
https://github.com/valeriangalliat/markdown-it-highlightjs | ||
https://github.com/brianjgeiger/markdown-it-ins-del | ||
https://github.com/svbergerem/markdown-it-sanitizer | ||
https://github.com/classeur/markdown-it-mathjax | ||
|
||
To add a new library, you need to make sure its loadable in md.js somehow, either through exporting via `root.<name>` or some other means. Some of the markdown plugins added have custom code in them to load them into `root`. | ||
|
||
Libraries should try to use the same version as the ones used on the OSF. The plugins do not matter as much, but `markdown-it` and `Mathjax` you should try to match exactly because styling can change between versions. | ||
|
||
To add a new library that is not already set up to export to `root` can be a bit tricky but the gist of it is, wrap the plugin in this code: | ||
|
||
```javascript | ||
;(function (root, factory) { | ||
if (typeof exports === 'object') { | ||
module.exports = factory() | ||
} else { | ||
root.<PLUGIN_NAME> = factory() | ||
} | ||
})(this, function () { | ||
|
||
|
||
return function(md){ | ||
|
||
..... | ||
} | ||
|
||
}) | ||
``` | ||
|
||
And then modify it to work in this context. See other plugins for examples. | ||
|
||
Then in md.js, you can add a plugin to the markdown renderer by adding a `.use(window.<PLUGIN_NAME>)` after loading the file into `viewer.mako`. | ||
For MFR, a customized local copy of each script is stored in the extension's static folder. There are a few issues: | ||
|
||
* ES5 compatibility: use [Babel](https://babeljs.io/repl/) to convert ES6 `markdown-it-highlightjs` to ES5. | ||
|
||
* `require` is NOT available. For `md.js` to be able to load these libraries, customization is necessary to export via `root.<PLUGIN_NAME>`. | ||
* `markdown-it` and `markdown-it-sanitizer` are already set up to be exported code. We load the `min` version directly. | ||
* `markdown-it-toc`, `markdown-it-highlightjs`, `markdown-it-ins-del` and `markdown-it-mathjax` are not. Here is the wrapper: | ||
```javascript | ||
(function (root, factory) { | ||
if (typeof exports === "object") { | ||
module.exports = factory(); | ||
} else { | ||
root.<PLUGIN_NAME> = factory(); | ||
} | ||
}) (this, function () { | ||
return function(md/*, optional arguments*/) { | ||
/* library code */ | ||
} | ||
}); | ||
``` | ||
|
||
Here is a list of original copy of the scripts we use: | ||
|
||
* [markdown-it@08.4.0](https://github.com/markdown-it/markdown-it/blob/8.4.0/bin/markdown-it.js) | ||
* [markdown-it-sanitizer@0.4.3](https://github.com/svbergerem/markdown-it-sanitizer/blob/v0.4.3/dist/markdown-it-sanitizer.min.js) | ||
* [markdown-it-mathjax@2.0.0](https://github.com/classeur/markdown-it-mathjax/blob/v2.0.0/markdown-it-mathjax.js) | ||
* [markdown-it-toc@1.1.1](https://github.com/cos-forks/markdown-it-toc/blob/1.1.1/index.js) | ||
* [markdown-it-ins-del@1.0.0](https://github.com/brianjgeiger/markdown-it-ins-del/blob/1.0.0/index.js) | ||
* [markdown-it-higlightjs@3.0.0](https://github.com/cslzchen/markdown-it-highlightjs/blob/release/3.0.0/index.es5.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
@charset "utf-8"; | ||
|
||
|
||
/*Had quite a few css woes on this one | ||
Chrome has some scroll bar issues. This is mostly due to | ||
Iframe problems. There may be a better combination of CSS to get rid of this, | ||
for now just going the best combination found. | ||
*/ | ||
.mfrViewer { | ||
font-family: 'Open Sans'; | ||
padding:1em; | ||
background:#fefefe; | ||
height: auto; | ||
word-wrap: break-word; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
/* | ||
Original highlight.js style (c) Ivan Sagalaev <[email protected]> | ||
*/ | ||
/** | ||
* Original highlight.js style (c) Ivan Sagalaev <[email protected]> | ||
* | ||
* https://github.com/isagalaev/highlight.js/blob/9.12.0/src/styles/default.css | ||
*/ | ||
|
||
.hljs { | ||
display: block; | ||
overflow-x: auto; | ||
padding: 0.5em; | ||
background: #F0F0F0; | ||
display: block; | ||
overflow-x: auto; | ||
padding: 0.5em; | ||
background: #F0F0F0; | ||
} | ||
|
||
|
||
/* Base color: saturation 0; */ | ||
|
||
.hljs, | ||
.hljs-subst { | ||
color: #444; | ||
color: #444; | ||
} | ||
|
||
.hljs-comment { | ||
color: #888888; | ||
color: #888888; | ||
} | ||
|
||
.hljs-keyword, | ||
|
@@ -29,7 +29,7 @@ Original highlight.js style (c) Ivan Sagalaev <[email protected]> | |
.hljs-meta-keyword, | ||
.hljs-doctag, | ||
.hljs-name { | ||
font-weight: bold; | ||
font-weight: bold; | ||
} | ||
|
||
|
||
|
@@ -43,13 +43,13 @@ Original highlight.js style (c) Ivan Sagalaev <[email protected]> | |
.hljs-quote, | ||
.hljs-template-tag, | ||
.hljs-deletion { | ||
color: #880000; | ||
color: #880000; | ||
} | ||
|
||
.hljs-title, | ||
.hljs-section { | ||
color: #880000; | ||
font-weight: bold; | ||
color: #880000; | ||
font-weight: bold; | ||
} | ||
|
||
.hljs-regexp, | ||
|
@@ -59,41 +59,41 @@ Original highlight.js style (c) Ivan Sagalaev <[email protected]> | |
.hljs-link, | ||
.hljs-selector-attr, | ||
.hljs-selector-pseudo { | ||
color: #BC6060; | ||
color: #BC6060; | ||
} | ||
|
||
|
||
/* Language color: hue: 90; */ | ||
|
||
.hljs-literal { | ||
color: #78A960; | ||
color: #78A960; | ||
} | ||
|
||
.hljs-built_in, | ||
.hljs-bullet, | ||
.hljs-code, | ||
.hljs-addition { | ||
color: #397300; | ||
color: #397300; | ||
} | ||
|
||
|
||
/* Meta color: hue: 200 */ | ||
|
||
.hljs-meta { | ||
color: #1f7199; | ||
color: #1f7199; | ||
} | ||
|
||
.hljs-meta-string { | ||
color: #4d99bf; | ||
color: #4d99bf; | ||
} | ||
|
||
|
||
/* Misc effects */ | ||
|
||
.hljs-emphasis { | ||
font-style: italic; | ||
font-style: italic; | ||
} | ||
|
||
.hljs-strong { | ||
font-weight: bold; | ||
font-weight: bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters