-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7348871
commit 9a5eeda
Showing
19 changed files
with
7,777 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
lib/ |
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,2 +1,41 @@ | ||
# markdown | ||
A package for rendering Markdown within Jupyter notebooks | ||
# @nteract/markdown | ||
|
||
This package contains components that allow us to render Markdown text per the Commonmark specification. It also supports rendering in-line and block math using the LaTeX syntax. | ||
|
||
## Installation | ||
|
||
``` | ||
$ yarn add @nteract/markdown | ||
``` | ||
|
||
``` | ||
$ npm install --save @nteract/markdown | ||
``` | ||
|
||
## Usage | ||
|
||
The example below shows how we can use this package to render Commonmark-specified Markdown with LaTeX math. | ||
|
||
```javascript | ||
import MarkdownRender from "@nteract/markdown"; | ||
|
||
export default () => { | ||
return ( | ||
<MarkdownRender | ||
source={`Just some $\delta_{\alpha}$ math and __formatting__.`} | ||
/> | ||
); | ||
}; | ||
``` | ||
|
||
## Documentation | ||
|
||
You can view the reference documentation for `@nteract/markdown` in the the [examples](./examples.md). | ||
|
||
## Support | ||
|
||
If you experience an issue while using this package or have a feature request, please file an issue on the [issue board](https://github.com/nteract/markdown/issues). | ||
|
||
## License | ||
|
||
[BSD-3-Clause](https://choosealicense.com/licenses/bsd-3-clause/) |
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 |
---|---|---|
@@ -0,0 +1,287 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`markdown works as it should lets see: watching-paint-dry 1`] = ` | ||
<MarkdownRender | ||
source=" | ||
# Watching Paint Dry | ||
The composited _color_ of the **paint** must not change during drying. The | ||
optical blending function is used with this constraint to compensate for the new | ||
dry layer $C_{d}^{prime}$, when some volume $delta_{alpha}$ is removed from | ||
the wet layer. | ||
$$ | ||
C_{d}^{prime} = \\\\frac{alpha}{} | ||
$$ | ||
The dry layer of the canvas uses a relative height field to allow for unlimited | ||
volume of paint to be added, with a constraint only on the relative change in | ||
height between texels. | ||
" | ||
> | ||
<ReactMarkdown | ||
astPlugins={Array []} | ||
className="markdown-body " | ||
escapeHtml={false} | ||
parserOptions={Object {}} | ||
plugins={ | ||
Array [ | ||
[Function], | ||
] | ||
} | ||
rawSourcePos={false} | ||
renderers={ | ||
Object { | ||
"code": [Function], | ||
"inlineMath": [Function], | ||
"math": [Function], | ||
} | ||
} | ||
skipHtml={false} | ||
source=" | ||
# Watching Paint Dry | ||
The composited _color_ of the **paint** must not change during drying. The | ||
optical blending function is used with this constraint to compensate for the new | ||
dry layer $C_{d}^{prime}$, when some volume $delta_{alpha}$ is removed from | ||
the wet layer. | ||
$$ | ||
C_{d}^{prime} = \\\\frac{alpha}{} | ||
$$ | ||
The dry layer of the canvas uses a relative height field to allow for unlimited | ||
volume of paint to be added, with a constraint only on the relative change in | ||
height between texels. | ||
" | ||
sourcePos={false} | ||
transformLinkUri={[Function]} | ||
> | ||
<Root | ||
className="markdown-body " | ||
key="root-1-1-0" | ||
> | ||
<div | ||
className="markdown-body " | ||
> | ||
<Heading | ||
key="heading-2-1-0" | ||
level={1} | ||
> | ||
<h1> | ||
<TextRenderer | ||
key="text-2-3-0" | ||
nodeKey="text-2-3-0" | ||
value="Watching Paint Dry" | ||
> | ||
Watching Paint Dry | ||
</TextRenderer> | ||
</h1> | ||
</Heading> | ||
<p | ||
key="paragraph-4-1-1" | ||
> | ||
<TextRenderer | ||
key="text-4-1-0" | ||
nodeKey="text-4-1-0" | ||
value="The composited " | ||
> | ||
The composited | ||
</TextRenderer> | ||
<em | ||
key="emphasis-4-16-1" | ||
> | ||
<TextRenderer | ||
key="text-4-17-0" | ||
nodeKey="text-4-17-0" | ||
value="color" | ||
> | ||
color | ||
</TextRenderer> | ||
</em> | ||
<TextRenderer | ||
key="text-4-23-2" | ||
nodeKey="text-4-23-2" | ||
value=" of the " | ||
> | ||
of the | ||
</TextRenderer> | ||
<strong | ||
key="strong-4-31-3" | ||
> | ||
<TextRenderer | ||
key="text-4-33-0" | ||
nodeKey="text-4-33-0" | ||
value="paint" | ||
> | ||
paint | ||
</TextRenderer> | ||
</strong> | ||
<TextRenderer | ||
key="text-4-40-4" | ||
nodeKey="text-4-40-4" | ||
value=" must not change during drying. The | ||
optical blending function is used with this constraint to compensate for the new | ||
dry layer " | ||
> | ||
must not change during drying. The | ||
optical blending function is used with this constraint to compensate for the new | ||
dry layer | ||
</TextRenderer> | ||
<inlineMath | ||
data={ | ||
Object { | ||
"hChildren": Array [ | ||
Object { | ||
"type": "text", | ||
"value": "C_{d}^{prime}", | ||
}, | ||
], | ||
"hName": "span", | ||
"hProperties": Object { | ||
"className": "inlineMath", | ||
}, | ||
} | ||
} | ||
key="inlineMath-6-11-5" | ||
value="C_{d}^{prime}" | ||
> | ||
<MathJaxNode | ||
inline={true} | ||
onRender={null} | ||
> | ||
<Provider | ||
delay={0} | ||
didFinishTypeset={null} | ||
input="tex" | ||
loading={null} | ||
noGate={false} | ||
onError={[Function]} | ||
onLoad={null} | ||
options={Object {}} | ||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML" | ||
> | ||
<MathJaxNode | ||
inline={true} | ||
onRender={null} | ||
/> | ||
</Provider> | ||
</MathJaxNode> | ||
</inlineMath> | ||
<TextRenderer | ||
key="text-6-26-6" | ||
nodeKey="text-6-26-6" | ||
value=", when some volume " | ||
> | ||
, when some volume | ||
</TextRenderer> | ||
<inlineMath | ||
data={ | ||
Object { | ||
"hChildren": Array [ | ||
Object { | ||
"type": "text", | ||
"value": "delta_{alpha}", | ||
}, | ||
], | ||
"hName": "span", | ||
"hProperties": Object { | ||
"className": "inlineMath", | ||
}, | ||
} | ||
} | ||
key="inlineMath-6-45-7" | ||
value="delta_{alpha}" | ||
> | ||
<MathJaxNode | ||
inline={true} | ||
onRender={null} | ||
> | ||
<Provider | ||
delay={0} | ||
didFinishTypeset={null} | ||
input="tex" | ||
loading={null} | ||
noGate={false} | ||
onError={[Function]} | ||
onLoad={null} | ||
options={Object {}} | ||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML" | ||
> | ||
<MathJaxNode | ||
inline={true} | ||
onRender={null} | ||
/> | ||
</Provider> | ||
</MathJaxNode> | ||
</inlineMath> | ||
<TextRenderer | ||
key="text-6-60-8" | ||
nodeKey="text-6-60-8" | ||
value=" is removed from | ||
the wet layer." | ||
> | ||
is removed from | ||
the wet layer. | ||
</TextRenderer> | ||
</p> | ||
<math | ||
data={ | ||
Object { | ||
"hChildren": Array [ | ||
Object { | ||
"type": "text", | ||
"value": "C_{d}^{prime} = \\\\frac{alpha}{}", | ||
}, | ||
], | ||
"hName": "div", | ||
"hProperties": Object { | ||
"className": "math", | ||
}, | ||
} | ||
} | ||
key="math-9-1-2" | ||
value="C_{d}^{prime} = \\\\frac{alpha}{}" | ||
> | ||
<MathJaxNode | ||
inline={false} | ||
onRender={null} | ||
> | ||
<Provider | ||
delay={0} | ||
didFinishTypeset={null} | ||
input="tex" | ||
loading={null} | ||
noGate={false} | ||
onError={[Function]} | ||
onLoad={null} | ||
options={Object {}} | ||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML" | ||
> | ||
<MathJaxNode | ||
inline={false} | ||
onRender={null} | ||
/> | ||
</Provider> | ||
</MathJaxNode> | ||
</math> | ||
<p | ||
key="paragraph-13-1-3" | ||
> | ||
<TextRenderer | ||
key="text-13-1-0" | ||
nodeKey="text-13-1-0" | ||
value="The dry layer of the canvas uses a relative height field to allow for unlimited | ||
volume of paint to be added, with a constraint only on the relative change in | ||
height between texels." | ||
> | ||
The dry layer of the canvas uses a relative height field to allow for unlimited | ||
volume of paint to be added, with a constraint only on the relative change in | ||
height between texels. | ||
</TextRenderer> | ||
</p> | ||
</div> | ||
</Root> | ||
</ReactMarkdown> | ||
</MarkdownRender> | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { mount } from "enzyme"; | ||
import toJson from "enzyme-to-json"; | ||
import * as React from "react"; | ||
|
||
import Markdown from "../src"; | ||
|
||
const cases = [ | ||
{ | ||
source: ` | ||
# Watching Paint Dry | ||
The composited _color_ of the **paint** must not change during drying. The | ||
optical blending function is used with this constraint to compensate for the new | ||
dry layer $C_{d}^{\prime}$, when some volume $\delta_{\alpha}$ is removed from | ||
the wet layer. | ||
$$ | ||
C_{d}^{\prime} = \\frac{\alpha}{} | ||
$$ | ||
The dry layer of the canvas uses a relative height field to allow for unlimited | ||
volume of paint to be added, with a constraint only on the relative change in | ||
height between texels. | ||
`, | ||
name: "watching-paint-dry" | ||
} | ||
]; | ||
|
||
describe("markdown works as it should", () => { | ||
test("lets see", () => { | ||
cases.forEach(({ source, name }) => { | ||
const wrapper = mount(<Markdown source={source} />); | ||
expect(toJson(wrapper)).toMatchSnapshot(name); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.